libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp b/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
new file mode 100644
index 0000000..2346b9d
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter> 
+//   OutIter
+//   copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp b/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
new file mode 100644
index 0000000..0a02e47
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter> 
+//   requires OutputIterator<OutIter, InIter::reference> 
+//   OutIter
+//   copy_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp b/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
new file mode 100644
index 0000000..866a919
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, 
+//          Predicate<auto, InIter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   OutIter
+//   copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct Pred
+{
+    bool operator()(int i) {return i % 3 == 0;}
+};
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_if(InIter(ia), InIter(ia+N), OutIter(ib), Pred());
+    assert(base(r) == ib+N/3+1);
+    for (unsigned i = 0; i < N/3+1; ++i)
+        assert(ib[i] % 3 == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp b/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
new file mode 100644
index 0000000..2e1ddae
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter> 
+//   OutIter
+//   copy_n(InIter first, InIter::difference_type n, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_n(InIter(ia), N/2, OutIter(ib));
+    assert(base(r) == ib+N/2);
+    for (unsigned i = 0; i < N/2; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp b/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
new file mode 100644
index 0000000..5f5009b
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires OutputIterator<Iter, const T&> 
+//   void
+//   fill(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test_char()
+{
+    const unsigned n = 4;
+    char ca[n] = {0};
+    std::fill(Iter(ca), Iter(ca+n), char(1));
+    assert(ca[0] == 1);
+    assert(ca[1] == 1);
+    assert(ca[2] == 1);
+    assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    std::fill(Iter(ia), Iter(ia+n), 1);
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+int main()
+{
+    test_char<forward_iterator<char*> >();
+    test_char<bidirectional_iterator<char*> >();
+    test_char<random_access_iterator<char*> >();
+    test_char<char*>();
+
+    test_int<forward_iterator<int*> >();
+    test_int<bidirectional_iterator<int*> >();
+    test_int<random_access_iterator<int*> >();
+    test_int<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
new file mode 100644
index 0000000..8728499
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, class T> 
+//   requires OutputIterator<Iter, const T&> 
+//   OutputIterator
+//   fill_n(Iter first, Size n, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test_char()
+{
+    const unsigned n = 4;
+    char ca[n] = {0};
+    assert(std::fill_n(Iter(ca), n, char(1)) == std::next(Iter(ca), n));
+    assert(ca[0] == 1);
+    assert(ca[1] == 1);
+    assert(ca[2] == 1);
+    assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::fill_n(Iter(ia), n, 1) == std::next(Iter(ia), n));
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+int main()
+{
+    test_char<forward_iterator<char*> >();
+    test_char<bidirectional_iterator<char*> >();
+    test_char<random_access_iterator<char*> >();
+    test_char<char*>();
+
+    test_int<forward_iterator<int*> >();
+    test_int<bidirectional_iterator<int*> >();
+    test_int<random_access_iterator<int*> >();
+    test_int<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp b/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
new file mode 100644
index 0000000..86772e4
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Callable Generator> 
+//   requires OutputIterator<Iter, Generator::result_type> 
+//         && CopyConstructible<Generator> 
+//   void
+//   generate(Iter first, Iter last, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct gen_test
+{
+    int operator()() const {return 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    std::generate(Iter(ia), Iter(ia+n), gen_test());
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp b/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
new file mode 100644
index 0000000..afc7191
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, Callable Generator>
+//   requires OutputIterator<Iter, Generator::result_type> 
+//         && CopyConstructible<Generator> 
+//   void
+//   generate_n(Iter first, Size n, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct gen_test
+{
+    int operator()() const {return 2;}
+};
+
+template <class Iter>
+void
+test()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::generate_n(Iter(ia), n, gen_test()) == Iter(ia+n));
+    assert(ia[0] == 2);
+    assert(ia[1] == 2);
+    assert(ia[2] == 2);
+    assert(ia[3] == 2);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
new file mode 100644
index 0000000..633519f
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter> 
+//   requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type> 
+//   OutIter
+//   move(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+    const unsigned N = 100;
+    std::unique_ptr<int> ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::unique_ptr<int> ib[N];
+
+    OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(*ib[i] == i);
+}
+
+#endif
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifdef _LIBCPP_MOVE
+    test1<input_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<forward_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, output_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, input_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
new file mode 100644
index 0000000..16ce401
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter> 
+//   requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type> 
+//   OutIter
+//   move_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+    const unsigned N = 100;
+    std::unique_ptr<int> ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::unique_ptr<int> ib[N];
+
+    OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(*ib[i] == i);
+}
+
+#endif
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifdef _LIBCPP_MOVE
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
new file mode 100644
index 0000000..0fb31f6
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//     bool
+//     is_partitioned(InputIterator first, InputIterator last, Predicate pred);
+
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {1, 2, 3, 4, 5, 6};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6};
+        assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {2, 4, 6, 1, 3, 5};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::begin(ia)),
+                                    is_odd()));
+    }
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp b/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
new file mode 100644
index 0000000..2e20bcc
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Pred> 
+//   Iter
+//   partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    // check mixed
+    int ia[] = {1, 2, 3, 4, 5, 6, 7, 8 ,9};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::partition(Iter(ia), Iter(ia + sa), is_odd());
+    assert(base(r) == ia + 5);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check empty
+    r = std::partition(Iter(ia), Iter(ia), is_odd());
+    assert(base(r) == ia);
+    // check all false
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia);
+    // check all true
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa);
+    // check all true but last
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    ia[sa-1] = 10;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa-1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all true but first
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    ia[0] = 10;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa-1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all false but last
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    ia[sa-1] = 11;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all false but first
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    ia[0] = 11;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
new file mode 100644
index 0000000..3f1fb4d
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class OutputIterator1,
+//           class OutputIterator2, class Predicate>
+//     pair<OutputIterator1, OutputIterator2>
+//     partition_copy(InputIterator first, InputIterator last,
+//                    OutputIterator1 out_true, OutputIterator2 out_false,
+//                    Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {1, 2, 3, 4, 6, 8, 5, 7};
+        int r1[10] = {0};
+        int r2[10] = {0};
+        typedef std::pair<output_iterator<int*>,  int*> P;
+        P p = std::partition_copy(input_iterator<const int*>(std::begin(ia)),
+                                  input_iterator<const int*>(std::end(ia)),
+                                  output_iterator<int*>(r1), r2, is_odd());
+        assert(p.first.base() == r1 + 4);
+        assert(r1[0] == 1);
+        assert(r1[1] == 3);
+        assert(r1[2] == 5);
+        assert(r1[3] == 7);
+        assert(p.second == r2 + 4);
+        assert(r2[0] == 2);
+        assert(r2[1] == 4);
+        assert(r2[2] == 6);
+        assert(r2[3] == 8);
+    }
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp b/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
new file mode 100644
index 0000000..ad232c2
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Predicate>
+//     ForwardIterator
+//     partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {2, 4, 6, 8, 10};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia));
+    }
+    {
+        const int ia[] = {1, 2, 4, 6, 8};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 1));
+    }
+    {
+        const int ia[] = {1, 3, 2, 4, 6};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 2));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 3));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 2, 4};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 4));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 9, 2};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 5));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 9, 11};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 6));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::begin(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia));
+    }
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp b/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
new file mode 100644
index 0000000..3b1aace
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
@@ -0,0 +1,314 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Pred> 
+//   Iter
+//   stable_partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+struct odd_first
+{
+    bool operator()(const std::pair<int,int>& p) const
+        {return p.first & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    {  // check mixed
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(1, 1),
+        P(1, 2),
+        P(2, 1),
+        P(2, 2),
+        P(3, 1),
+        P(3, 2),
+        P(4, 1),
+        P(4, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 4);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(0, 1));
+    assert(array[5] == P(0, 2));
+    assert(array[6] == P(2, 1));
+    assert(array[7] == P(2, 2));
+    assert(array[8] == P(4, 1));
+    assert(array[9] == P(4, 2));
+    }
+    {
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(1, 1),
+        P(1, 2),
+        P(2, 1),
+        P(2, 2),
+        P(3, 1),
+        P(3, 2),
+        P(4, 1),
+        P(4, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 4);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(0, 1));
+    assert(array[5] == P(0, 2));
+    assert(array[6] == P(2, 1));
+    assert(array[7] == P(2, 2));
+    assert(array[8] == P(4, 1));
+    assert(array[9] == P(4, 2));
+    // check empty
+    r = std::stable_partition(Iter(array), Iter(array), odd_first());
+    assert(base(r) == array);
+    // check one true
+    r = std::stable_partition(Iter(array), Iter(array+1), odd_first());
+    assert(base(r) == array+1);
+    assert(array[0] == P(1, 1));
+    // check one false
+    r = std::stable_partition(Iter(array+4), Iter(array+5), odd_first());
+    assert(base(r) == array+4);
+    assert(array[4] == P(0, 1));
+    }
+    {  // check all false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(8, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array);
+    assert(array[0] == P(0, 1));
+    assert(array[1] == P(0, 2));
+    assert(array[2] == P(2, 1));
+    assert(array[3] == P(2, 2));
+    assert(array[4] == P(4, 1));
+    assert(array[5] == P(4, 2));
+    assert(array[6] == P(6, 1));
+    assert(array[7] == P(6, 2));
+    assert(array[8] == P(8, 1));
+    assert(array[9] == P(8, 2));
+    }
+    {  // check all true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(9, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(5, 1));
+    assert(array[5] == P(5, 2));
+    assert(array[6] == P(7, 1));
+    assert(array[7] == P(7, 2));
+    assert(array[8] == P(9, 1));
+    assert(array[9] == P(9, 2));
+    }
+    {  // check all false but first true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(8, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 1);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(0, 2));
+    assert(array[2] == P(2, 1));
+    assert(array[3] == P(2, 2));
+    assert(array[4] == P(4, 1));
+    assert(array[5] == P(4, 2));
+    assert(array[6] == P(6, 1));
+    assert(array[7] == P(6, 2));
+    assert(array[8] == P(8, 1));
+    assert(array[9] == P(8, 2));
+    }
+    {  // check all false but last true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(1, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 1);
+    assert(array[0] == P(1, 2));
+    assert(array[1] == P(0, 1));
+    assert(array[2] == P(0, 2));
+    assert(array[3] == P(2, 1));
+    assert(array[4] == P(2, 2));
+    assert(array[5] == P(4, 1));
+    assert(array[6] == P(4, 2));
+    assert(array[7] == P(6, 1));
+    assert(array[8] == P(6, 2));
+    assert(array[9] == P(8, 1));
+    }
+    {  // check all true but first false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(9, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size-1);
+    assert(array[0] == P(1, 2));
+    assert(array[1] == P(3, 1));
+    assert(array[2] == P(3, 2));
+    assert(array[3] == P(5, 1));
+    assert(array[4] == P(5, 2));
+    assert(array[5] == P(7, 1));
+    assert(array[6] == P(7, 2));
+    assert(array[7] == P(9, 1));
+    assert(array[8] == P(9, 2));
+    assert(array[9] == P(0, 1));
+    }
+    {  // check all true but last false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(0, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size-1);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(5, 1));
+    assert(array[5] == P(5, 2));
+    assert(array[6] == P(7, 1));
+    assert(array[7] == P(7, 2));
+    assert(array[8] == P(9, 1));
+    assert(array[9] == P(0, 2));
+    }
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct is_null
+{
+    template <class P>
+        bool operator()(const P& p) {return p == 0;}
+};
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned size = 5;
+    std::unique_ptr<int> array[size];
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), is_null());
+}
+
+#endif
+
+int main()
+{
+    test<bidirectional_iterator<std::pair<int,int>*> >();
+    test<random_access_iterator<std::pair<int,int>*> >();
+    test<std::pair<int,int>*>();
+
+#ifdef _LIBCPP_MOVE
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
new file mode 100644
index 0000000..273e8df
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//   void
+//   random_shuffle(Iter first, Iter last);
+
+#include <algorithm>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::random_shuffle(ia, ia+sa);
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
new file mode 100644
index 0000000..e9c54b1
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand> 
+//   requires ShuffleIterator<Iter> 
+//         && Convertible<Rand::result_type, Iter::difference_type> 
+//   void
+//   random_shuffle(Iter first, Iter last, Rand&& rand);
+
+#include <algorithm>
+
+#include "../../iterators.h"
+
+struct gen
+{
+    int operator()(int n)
+    {
+        return 0;
+    }
+};
+
+int main()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    gen r;
+    std::random_shuffle(ia, ia+sa, r);
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
new file mode 100644
index 0000000..829136c
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, UniformRandomNumberGenerator Rand> 
+//   void
+//   random_shuffle(Iter first, Iter last, Rand&& g);
+
+#include <algorithm>
+
+#error random_shuffle for UniformRandomNumberGenerator not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp b/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
new file mode 100644
index 0000000..2fafc47
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type> 
+//         && HasEqualTo<Iter::value_type, T> 
+//   Iter
+//   remove(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::remove(Iter(ia), Iter(ia+sa), 2);
+    assert(base(r) == ia + sa-3);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 3);
+    assert(ia[3] == 4);
+    assert(ia[4] == 3);
+    assert(ia[5] == 4);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned sa = 9;
+    std::unique_ptr<int> ia[sa];
+    ia[0].reset(new int(0));
+    ia[1].reset(new int(1));
+    ia[3].reset(new int(3));
+    ia[4].reset(new int(4));
+    ia[6].reset(new int(3));
+    ia[7].reset(new int(4));
+    Iter r = std::remove(Iter(ia), Iter(ia+sa), std::unique_ptr<int>());
+    assert(base(r) == ia + sa-3);
+    assert(*ia[0] == 0);
+    assert(*ia[1] == 1);
+    assert(*ia[2] == 3);
+    assert(*ia[3] == 4);
+    assert(*ia[4] == 3);
+    assert(*ia[5] == 4);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
new file mode 100644
index 0000000..3cbb766
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T> 
+//   requires HasEqualTo<InIter::value_type, T> 
+//   OutIter
+//   remove_copy(InIter first, InIter last, OutIter result, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa];
+    OutIter r = std::remove_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2);
+    assert(base(r) == ib + sa-3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 3);
+    assert(ib[5] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
new file mode 100644
index 0000000..9d822bc
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, 
+//          Predicate<auto, InIter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   OutIter
+//   remove_copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa];
+    OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+                                    std::bind2nd(std::equal_to<int>(), 2));
+    assert(base(r) == ib + sa-3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 3);
+    assert(ib[5] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp b/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
new file mode 100644
index 0000000..eb93bff
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type> 
+//         && CopyConstructible<Pred> 
+//   Iter
+//   remove_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int* r = std::remove_if(ia, ia+sa, std::bind2nd(std::equal_to<int>(), 2));
+    assert(r == ia + sa-3);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 3);
+    assert(ia[3] == 4);
+    assert(ia[4] == 3);
+    assert(ia[5] == 4);
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct pred
+{
+    bool operator()(const std::unique_ptr<int>& i) {return *i == 2;}
+};
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned sa = 9;
+    std::unique_ptr<int> ia[sa];
+    ia[0].reset(new int(0));
+    ia[1].reset(new int(1));
+    ia[2].reset(new int(2));
+    ia[3].reset(new int(3));
+    ia[4].reset(new int(4));
+    ia[5].reset(new int(2));
+    ia[6].reset(new int(3));
+    ia[7].reset(new int(4));
+    ia[8].reset(new int(2));
+    Iter r = std::remove_if(Iter(ia), Iter(ia+sa), pred());
+    assert(base(r) == ia + sa-3);
+    assert(*ia[0] == 0);
+    assert(*ia[1] == 1);
+    assert(*ia[2] == 3);
+    assert(*ia[3] == 4);
+    assert(*ia[4] == 3);
+    assert(*ia[5] == 4);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp b/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp
new file mode 100644
index 0000000..51b0543
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.replace/replace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires OutputIterator<Iter, Iter::reference>
+//         && OutputIterator<Iter, const T&>
+//         && HasEqualTo<Iter::value_type, T> 
+//   void
+//   replace(Iter first, Iter last, const T& old_value, const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::replace(Iter(ia), Iter(ia+sa), 2, 5);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 5);
+    assert(ia[3] == 3);
+    assert(ia[4] == 4);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
new file mode 100644
index 0000000..d3648f6
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter, class T> 
+//   requires OutputIterator<OutIter, InIter::reference> 
+//         && OutputIterator<OutIter, const T&> 
+//         && HasEqualTo<InIter::value_type, T> 
+//   OutIter
+//   replace_copy(InIter first, InIter last, OutIter result, const T& old_value,
+//                                                           const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::replace_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2, 5);
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 5);
+    assert(ib[3] == 3);
+    assert(ib[4] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
new file mode 100644
index 0000000..65371ec
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter, 
+//          Predicate<auto, InIter::value_type> Pred, class T> 
+//   requires OutputIterator<OutIter, InIter::reference> 
+//         && OutputIterator<OutIter, const T&> 
+//         && CopyConstructible<Pred> 
+//   OutIter
+//   replace_copy_if(InIter first, InIter last, OutIter result, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+                                     std::bind2nd(std::equal_to<int>(), 2), 5);
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 5);
+    assert(ib[3] == 3);
+    assert(ib[4] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
new file mode 100644
index 0000000..8cf7601
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.replace/replace_if.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred, class T> 
+//   requires OutputIterator<Iter, Iter::reference> 
+//         && OutputIterator<Iter, const T&> 
+//         && CopyConstructible<Pred> 
+//   void
+//   replace_if(Iter first, Iter last, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 5);
+    assert(ia[3] == 3);
+    assert(ia[4] == 4);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp b/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
new file mode 100644
index 0000000..f65c582
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter> 
+//   requires HasSwap<Iter::reference, Iter::reference> 
+//   void
+//   reverse(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::reverse(Iter(ia), Iter(ia));
+    assert(ia[0] == 0);
+    std::reverse(Iter(ia), Iter(ia+sa));
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    std::reverse(Iter(ib), Iter(ib+sb));
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    std::reverse(Iter(ic), Iter(ic+sc));
+    assert(ic[0] == 2);
+    assert(ic[1] == 1);
+    assert(ic[2] == 0);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    std::reverse(Iter(id), Iter(id+sd));
+    assert(id[0] == 3);
+    assert(id[1] == 2);
+    assert(id[2] == 1);
+    assert(id[3] == 0);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
new file mode 100644
index 0000000..82a81c0
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, OutputIterator<auto, InIter::reference> OutIter> 
+//   OutIter
+//   reverse_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    OutIter r = std::reverse_copy(InIter(ia), InIter(ia), OutIter(ja));
+    assert(base(r) == ja);
+    assert(ja[0] == -1);
+    r = std::reverse_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+    assert(ja[0] == 0);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    r = std::reverse_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+    assert(base(r) == jb+sb);
+    assert(jb[0] == 1);
+    assert(jb[1] == 0);
+
+    const int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    r = std::reverse_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+    assert(base(r) == jc+sc);
+    assert(jc[0] == 2);
+    assert(jc[1] == 1);
+    assert(jc[2] == 0);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    r = std::reverse_copy(InIter(id), InIter(id+sd), OutIter(jd));
+    assert(base(r) == jd+sd);
+    assert(jd[0] == 3);
+    assert(jd[1] == 2);
+    assert(jd[2] == 1);
+    assert(jd[3] == 0);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
new file mode 100644
index 0000000..5af9f75
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
@@ -0,0 +1,439 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ShuffleIterator Iter> 
+//   Iter
+//   rotate(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+    assert(base(r) == ia);
+    assert(ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia+sa);
+    assert(ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+    assert(base(r) == ia);
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib+sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+    r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+    assert(base(r) == ib);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic+sc);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+    assert(base(r) == ic+2);
+    assert(ic[0] == 1);
+    assert(ic[1] == 2);
+    assert(ic[2] == 0);
+    r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+    assert(base(r) == ic+1);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+    assert(base(r) == ic);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+    assert(base(r) == id+sd);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+    assert(id[2] == 2);
+    assert(id[3] == 3);
+    r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+    assert(base(r) == id+3);
+    assert(id[0] == 1);
+    assert(id[1] == 2);
+    assert(id[2] == 3);
+    assert(id[3] == 0);
+    r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+    assert(base(r) == id+2);
+    assert(id[0] == 3);
+    assert(id[1] == 0);
+    assert(id[2] == 1);
+    assert(id[3] == 2);
+    r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+    assert(base(r) == id+1);
+    assert(id[0] == 2);
+    assert(id[1] == 3);
+    assert(id[2] == 0);
+    assert(id[3] == 1);
+    r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+    assert(base(r) == id);
+    assert(id[0] == 2);
+    assert(id[1] == 3);
+    assert(id[2] == 0);
+    assert(id[3] == 1);
+
+    int ie[] = {0, 1, 2, 3, 4};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+    assert(base(r) == ie+se);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+    assert(base(r) == ie+4);
+    assert(ie[0] == 1);
+    assert(ie[1] == 2);
+    assert(ie[2] == 3);
+    assert(ie[3] == 4);
+    assert(ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+    assert(base(r) == ie+3);
+    assert(ie[0] == 3);
+    assert(ie[1] == 4);
+    assert(ie[2] == 0);
+    assert(ie[3] == 1);
+    assert(ie[4] == 2);
+    r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+    assert(base(r) == ie+2);
+    assert(ie[0] == 1);
+    assert(ie[1] == 2);
+    assert(ie[2] == 3);
+    assert(ie[3] == 4);
+    assert(ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+    assert(base(r) == ie+1);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+    assert(base(r) == ie);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+
+    int ig[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig+sg);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(ig[2] == 2);
+    assert(ig[3] == 3);
+    assert(ig[4] == 4);
+    assert(ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+    assert(base(r) == ig+5);
+    assert(ig[0] == 1);
+    assert(ig[1] == 2);
+    assert(ig[2] == 3);
+    assert(ig[3] == 4);
+    assert(ig[4] == 5);
+    assert(ig[5] == 0);
+    r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+    assert(base(r) == ig+4);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+    assert(base(r) == ig+3);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(ig[2] == 2);
+    assert(ig[3] == 3);
+    assert(ig[4] == 4);
+    assert(ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+    assert(base(r) == ig+2);
+    assert(ig[0] == 4);
+    assert(ig[1] == 5);
+    assert(ig[2] == 0);
+    assert(ig[3] == 1);
+    assert(ig[4] == 2);
+    assert(ig[5] == 3);
+    r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+    assert(base(r) == ig+1);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+    assert(base(r) == ig);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class Iter>
+void
+test1()
+{
+    std::unique_ptr<int> ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    for (int i = 0; i < sa; ++i)
+        ia[i].reset(new int(i));
+    Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+    assert(base(r) == ia);
+    assert(*ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia+sa);
+    assert(*ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+    assert(base(r) == ia);
+    assert(*ia[0] == 0);
+
+    std::unique_ptr<int> ib[2];
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    for (int i = 0; i < sb; ++i)
+        ib[i].reset(new int(i));
+    r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib+sb);
+    assert(*ib[0] == 0);
+    assert(*ib[1] == 1);
+    r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+    assert(base(r) == ib+1);
+    assert(*ib[0] == 1);
+    assert(*ib[1] == 0);
+    r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+    assert(base(r) == ib);
+    assert(*ib[0] == 1);
+    assert(*ib[1] == 0);
+
+    std::unique_ptr<int> ic[3];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    for (int i = 0; i < sc; ++i)
+        ic[i].reset(new int(i));
+    r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic+sc);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+    assert(base(r) == ic+2);
+    assert(*ic[0] == 1);
+    assert(*ic[1] == 2);
+    assert(*ic[2] == 0);
+    r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+    assert(base(r) == ic+1);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+    assert(base(r) == ic);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+
+    std::unique_ptr<int> id[4];
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    for (int i = 0; i < sd; ++i)
+        id[i].reset(new int(i));
+    r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+    assert(base(r) == id+sd);
+    assert(*id[0] == 0);
+    assert(*id[1] == 1);
+    assert(*id[2] == 2);
+    assert(*id[3] == 3);
+    r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+    assert(base(r) == id+3);
+    assert(*id[0] == 1);
+    assert(*id[1] == 2);
+    assert(*id[2] == 3);
+    assert(*id[3] == 0);
+    r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+    assert(base(r) == id+2);
+    assert(*id[0] == 3);
+    assert(*id[1] == 0);
+    assert(*id[2] == 1);
+    assert(*id[3] == 2);
+    r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+    assert(base(r) == id+1);
+    assert(*id[0] == 2);
+    assert(*id[1] == 3);
+    assert(*id[2] == 0);
+    assert(*id[3] == 1);
+    r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+    assert(base(r) == id);
+    assert(*id[0] == 2);
+    assert(*id[1] == 3);
+    assert(*id[2] == 0);
+    assert(*id[3] == 1);
+
+    std::unique_ptr<int> ie[5];
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    for (int i = 0; i < se; ++i)
+        ie[i].reset(new int(i));
+    r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+    assert(base(r) == ie+se);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+    assert(base(r) == ie+4);
+    assert(*ie[0] == 1);
+    assert(*ie[1] == 2);
+    assert(*ie[2] == 3);
+    assert(*ie[3] == 4);
+    assert(*ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+    assert(base(r) == ie+3);
+    assert(*ie[0] == 3);
+    assert(*ie[1] == 4);
+    assert(*ie[2] == 0);
+    assert(*ie[3] == 1);
+    assert(*ie[4] == 2);
+    r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+    assert(base(r) == ie+2);
+    assert(*ie[0] == 1);
+    assert(*ie[1] == 2);
+    assert(*ie[2] == 3);
+    assert(*ie[3] == 4);
+    assert(*ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+    assert(base(r) == ie+1);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+    assert(base(r) == ie);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+
+    std::unique_ptr<int> ig[6];
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    for (int i = 0; i < sg; ++i)
+        ig[i].reset(new int(i));
+    r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig+sg);
+    assert(*ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(*ig[2] == 2);
+    assert(*ig[3] == 3);
+    assert(*ig[4] == 4);
+    assert(*ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+    assert(base(r) == ig+5);
+    assert(*ig[0] == 1);
+    assert(*ig[1] == 2);
+    assert(*ig[2] == 3);
+    assert(*ig[3] == 4);
+    assert(*ig[4] == 5);
+    assert(*ig[5] == 0);
+    r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+    assert(base(r) == ig+4);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+    assert(base(r) == ig+3);
+    assert(*ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(*ig[2] == 2);
+    assert(*ig[3] == 3);
+    assert(*ig[4] == 4);
+    assert(*ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+    assert(base(r) == ig+2);
+    assert(*ig[0] == 4);
+    assert(*ig[1] == 5);
+    assert(*ig[2] == 0);
+    assert(*ig[3] == 1);
+    assert(*ig[4] == 2);
+    assert(*ig[5] == 3);
+    r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+    assert(base(r) == ig+1);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+    assert(base(r) == ig);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
new file mode 100644
index 0000000..9603766
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator InIter, OutputIterator<auto, InIter::reference> OutIter> 
+//   OutIter
+//   rotate_copy(InIter first, InIter middle, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+
+    OutIter r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia), OutIter(ib));
+    assert(base(r) == ib);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+1), OutIter(ib));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+1), OutIter(ib));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 2);
+    assert(ib[1] == 0);
+    assert(ib[2] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+    assert(ib[3] == 3);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 3);
+    assert(ib[3] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 2);
+    assert(ib[1] == 3);
+    assert(ib[2] == 0);
+    assert(ib[3] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 3);
+    assert(ib[1] == 0);
+    assert(ib[2] == 1);
+    assert(ib[3] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+4), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+    assert(ib[3] == 3);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp b/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
new file mode 100644
index 0000000..e126080
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<Iterator Iter1, Iterator Iter2> 
+//   requires HasSwap<Iter1::reference, Iter2::reference> 
+//   void
+//   iter_swap(Iter1 a, Iter2 b);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+    int i = 1;
+    int j = 2;
+    std::iter_swap(&i, &j);
+    assert(i == 2);
+    assert(j == 1);
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp b/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
new file mode 100644
index 0000000..38513f2
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2> 
+//   requires HasSwap<Iter1::reference, Iter2::reference> 
+//   Iter2
+//   swap_ranges(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template<class Iter1, class Iter2>
+void
+test()
+{
+    int i[3] = {1, 2, 3};
+    int j[3] = {4, 5, 6};
+    Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+    assert(base(r) == j+3);
+    assert(i[0] == 4);
+    assert(i[1] == 5);
+    assert(i[2] == 6);
+    assert(j[0] == 1);
+    assert(j[1] == 2);
+    assert(j[2] == 3);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template<class Iter1, class Iter2>
+void
+test1()
+{
+    std::unique_ptr<int> i[3];
+    for (int k = 0; k < 3; ++k)
+        i[k].reset(new int(k+1));
+    std::unique_ptr<int> j[3];
+    for (int k = 0; k < 3; ++k)
+        j[k].reset(new int(k+4));
+    Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+    assert(base(r) == j+3);
+    assert(*i[0] == 4);
+    assert(*i[1] == 5);
+    assert(*i[2] == 6);
+    assert(*j[0] == 1);
+    assert(*j[1] == 2);
+    assert(*j[2] == 3);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*>, forward_iterator<int*> >();
+    test<forward_iterator<int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<int*>, random_access_iterator<int*> >();
+    test<forward_iterator<int*>, int*>();
+
+    test<bidirectional_iterator<int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<int*>, int*>();
+
+    test<random_access_iterator<int*>, forward_iterator<int*> >();
+    test<random_access_iterator<int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<int*>, int*>();
+
+    test<int*, forward_iterator<int*> >();
+    test<int*, bidirectional_iterator<int*> >();
+    test<int*, random_access_iterator<int*> >();
+    test<int*, int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp b/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
new file mode 100644
index 0000000..7623edc
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
@@ -0,0 +1,217 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, class OutIter, 
+//          Callable<auto, const InIter1::value_type&, const InIter2::value_type&> BinaryOp> 
+//   requires OutputIterator<OutIter, BinaryOp::result_type> && CopyConstructible<BinaryOp> 
+// OutIter
+// transform(InIter1 first1, InIter1 last1, InIter2 first2, OutIter result, BinaryOp binary_op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template<class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {1, 2, 3, 4, 5};
+    OutIter r = std::transform(InIter1(ib), InIter1(ib+sa), InIter2(ia),
+                               OutIter(ib), std::minus<int>());
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 1);
+    assert(ib[1] == 1);
+    assert(ib[2] == 1);
+    assert(ib[3] == 1);
+    assert(ib[4] == 1);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, input_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
new file mode 100644
index 0000000..6300eb9
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter, 
+//          Callable<auto, const InIter::value_type&> Op> 
+//   requires OutputIterator<OutIter, Op::result_type> && CopyConstructible<Op> 
+//   OutIter
+//   transform(InIter first, InIter last, OutIter result, Op op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
+                               std::bind2nd(std::plus<int>(), 1));
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 5);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp b/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
new file mode 100644
index 0000000..26929d0
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
@@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires OutputIterator<Iter, Iter::reference>
+//         && EqualityComparable<Iter::value_type> 
+//   Iter
+//   unique(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::unique(Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::unique(Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::unique(Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+
+    int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::unique(Iter(id), Iter(id+sd));
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+
+    int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::unique(Iter(ie), Iter(ie+se));
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 0);
+
+    int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::unique(Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+
+    int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    r = std::unique(Iter(ih), Iter(ih+sh));
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(ih[1] == 1);
+
+    int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    r = std::unique(Iter(ii), Iter(ii+si));
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(ii[1] == 1);
+    assert(ii[2] == 2);
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+    int one = 1;
+    int two = 2;
+    Ptr ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::unique(Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+
+    Ptr ib[2];
+    ib[1].reset(&one);
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::unique(Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(*ib[1] == 1);
+
+    Ptr ic[2];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::unique(Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+
+    Ptr id[3];
+    id[2].reset(&one);
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::unique(Iter(id), Iter(id+sd));
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(*id[1] == 1);
+
+    Ptr ie[4];
+    ie[2].reset(&one);
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::unique(Iter(ie), Iter(ie+se));
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(ie[2] == 0);
+
+    Ptr ig[4];
+    ig[2].reset(&one);
+    ig[3].reset(&one);
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::unique(Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(*ig[1] == 1);
+
+    Ptr ih[3];
+    ih[1].reset(&one);
+    ih[2].reset(&one);
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    r = std::unique(Iter(ih), Iter(ih+sh));
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(*ih[1] == 1);
+
+    Ptr ii[7];
+    ii[1].reset(&one);
+    ii[2].reset(&one);
+    ii[3].reset(&one);
+    ii[4].reset(&two);
+    ii[5].reset(&two);
+    ii[6].reset(&two);
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    r = std::unique(Iter(ii), Iter(ii+si));
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(*ii[1] == 1);
+    assert(*ii[2] == 2);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<Ptr*> >();
+    test1<bidirectional_iterator<Ptr*> >();
+    test1<random_access_iterator<Ptr*> >();
+    test1<Ptr*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp b/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
new file mode 100644
index 0000000..8669d93
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter> 
+//   requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type> 
+//         && EqualityComparable<InIter::value_type> 
+//         && HasAssign<InIter::value_type, InIter::reference> 
+//         && Constructible<InIter::value_type, InIter::reference> 
+//   OutIter
+//   unique_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+    assert(base(r) == ja + sa);
+    assert(ja[0] == 0);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+    assert(base(r) == jb + sb);
+    assert(jb[0] == 0);
+    assert(jb[1] == 1);
+
+    const int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+    assert(base(r) == jc + 1);
+    assert(jc[0] == 0);
+
+    const int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd));
+    assert(base(r) == jd + 2);
+    assert(jd[0] == 0);
+    assert(jd[1] == 1);
+
+    const int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    int je[se] = {-1};
+    r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je));
+    assert(base(r) == je + 3);
+    assert(je[0] == 0);
+    assert(je[1] == 1);
+    assert(je[2] == 0);
+
+    const int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    int jg[sg] = {-1};
+    r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg));
+    assert(base(r) == jg + 2);
+    assert(jg[0] == 0);
+    assert(jg[1] == 1);
+
+    const int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int jh[sh] = {-1};
+    r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh));
+    assert(base(r) == jh + 2);
+    assert(jh[0] == 0);
+    assert(jh[1] == 1);
+
+    const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    int ji[si] = {-1};
+    r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji));
+    assert(base(r) == ji + 3);
+    assert(ji[0] == 0);
+    assert(ji[1] == 1);
+    assert(ji[2] == 2);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp b/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
new file mode 100644
index 0000000..a0ef1d4
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter, 
+//          EquivalenceRelation<auto, InIter::value_type> Pred> 
+//   requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type> 
+//         && HasAssign<InIter::value_type, InIter::reference> 
+//         && Constructible<InIter::value_type, InIter::reference> 
+//         && CopyConstructible<Pred> 
+//   OutIter
+//   unique_copy(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    count_equal::count = 0;
+    OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja), count_equal());
+    assert(base(r) == ja + sa);
+    assert(ja[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb), count_equal());
+    assert(base(r) == jb + sb);
+    assert(jb[0] == 0);
+    assert(jb[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    const int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc), count_equal());
+    assert(base(r) == jc + 1);
+    assert(jc[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    const int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd), count_equal());
+    assert(base(r) == jd + 2);
+    assert(jd[0] == 0);
+    assert(jd[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    const int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    int je[se] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je), count_equal());
+    assert(base(r) == je + 3);
+    assert(je[0] == 0);
+    assert(je[1] == 1);
+    assert(je[2] == 0);
+    assert(count_equal::count == se-1);
+
+    const int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    int jg[sg] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg), count_equal());
+    assert(base(r) == jg + 2);
+    assert(jg[0] == 0);
+    assert(jg[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    const int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int jh[sh] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh), count_equal());
+    assert(base(r) == jh + 2);
+    assert(jh[0] == 0);
+    assert(jh[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    int ji[si] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji), count_equal());
+    assert(base(r) == ji + 3);
+    assert(ji[0] == 0);
+    assert(ji[1] == 1);
+    assert(ji[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp b/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
new file mode 100644
index 0000000..36f0e39
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred> 
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type> 
+//         && CopyConstructible<Pred> 
+//   Iter
+//   unique(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(id), Iter(id+sd), count_equal());
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 0);
+    assert(count_equal::count == se-1);
+
+    int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(ih[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(ii[1] == 1);
+    assert(ii[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+    int one = 1;
+    int two = 2;
+    Ptr ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    Ptr ib[2];
+    ib[1].reset(&one);
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(*ib[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    Ptr ic[2];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    Ptr id[3];
+    id[2].reset(&one);
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(id), Iter(id+sd), count_equal());
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(*id[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    Ptr ie[4];
+    ie[2].reset(&one);
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(ie[2] == 0);
+    assert(count_equal::count == se-1);
+
+    Ptr ig[4];
+    ig[2].reset(&one);
+    ig[3].reset(&one);
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    Ptr ih[3];
+    ih[1].reset(&one);
+    ih[2].reset(&one);
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(*ih[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    Ptr ii[7];
+    ii[1].reset(&one);
+    ii[2].reset(&one);
+    ii[3].reset(&one);
+    ii[4].reset(&two);
+    ii[5].reset(&two);
+    ii[6].reset(&two);
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(*ii[1] == 1);
+    assert(*ii[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+#endif
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+
+    test1<forward_iterator<Ptr*> >();
+    test1<bidirectional_iterator<Ptr*> >();
+    test1<random_access_iterator<Ptr*> >();
+    test1<Ptr*>();
+
+#endif
+}
diff --git a/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp b/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp b/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
new file mode 100644
index 0000000..467af8b
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires EqualityComparable<Iter::value_type> 
+//   Iter
+//   adjacent_find(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia + sa)) ==
+                              forward_iterator<const int*>(ia+2));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia)) ==
+                              forward_iterator<const int*>(ia));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+                              forward_iterator<const int*>(ia + sa)) ==
+                              forward_iterator<const int*>(ia+sa));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
new file mode 100644
index 0000000..db061a7
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter
+//   adjacent_find(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia + sa),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia+2));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+                              forward_iterator<const int*>(ia + sa),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia+sa));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp b/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
new file mode 100644
index 0000000..9744036
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   all_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == true);
+    }
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp b/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
new file mode 100644
index 0000000..bedd3a4
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   any_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+    {
+        const int ia[] = {1, 3, 5, 7};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp
new file mode 100644
index 0000000..47356bc
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.count/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T> 
+//   requires HasEqualTo<Iter::value_type, T> 
+//   Iter::difference_type
+//   count(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia + sa), 2) == 3);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia + sa), 7) == 0);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia), 2) == 0);
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
new file mode 100644
index 0000000..f1a4e13
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.count/count_if.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter::difference_type
+//   count_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         std::bind2nd(std::equal_to<int>(),2)) == 3);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         std::bind2nd(std::equal_to<int>(),7)) == 0);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia),
+                         std::bind2nd(std::equal_to<int>(),2)) == 0);
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
new file mode 100644
index 0000000..a8995d2
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   bool
+//   equal(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    int ib[s] = {0, 1, 2, 5, 4, 5};
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia)));
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib)));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp
new file mode 100644
index 0000000..5769515
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, 
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   bool
+//   equal(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    int ib[s] = {0, 1, 2, 5, 4, 5};
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia),
+                      std::equal_to<int>()));
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib),
+                       std::equal_to<int>()));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
new file mode 100644
index 0000000..afce49a
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   Iter1
+//   find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int b[] = {0};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1)) == Iter1(ia+sa-1));
+    int c[] = {0, 1};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2)) == Iter1(ia+18));
+    int d[] = {0, 1, 2};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3)) == Iter1(ia+15));
+    int e[] = {0, 1, 2, 3};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4)) == Iter1(ia+11));
+    int f[] = {0, 1, 2, 3, 4};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5)) == Iter1(ia+6));
+    int g[] = {0, 1, 2, 3, 4, 5};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6)) == Iter1(ia));
+    int h[] = {0, 1, 2, 3, 4, 5, 6};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7)) == Iter1(ia+sa));
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b)) == Iter1(ia+sa));
+    assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1)) == Iter1(ia));
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
new file mode 100644
index 0000000..de3037d
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2, 
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter1
+//   find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int b[] = {0};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= 1*(sa-1+1));
+    int c[] = {0, 1};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2), count_equal()) == Iter1(ia+18));
+    assert(count_equal::count <= 2*(sa-2+1));
+    int d[] = {0, 1, 2};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3), count_equal()) == Iter1(ia+15));
+    assert(count_equal::count <= 3*(sa-3+1));
+    int e[] = {0, 1, 2, 3};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4), count_equal()) == Iter1(ia+11));
+    assert(count_equal::count <= 4*(sa-4+1));
+    int f[] = {0, 1, 2, 3, 4};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5), count_equal()) == Iter1(ia+6));
+    assert(count_equal::count <= 5*(sa-5+1));
+    int g[] = {0, 1, 2, 3, 4, 5};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 6*(sa-6+1));
+    int h[] = {0, 1, 2, 3, 4, 5, 6};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7), count_equal()) == Iter1(ia+sa));
+    assert(count_equal::count <= 7*(sa-7+1));
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b), count_equal()) == Iter1(ia+sa));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
new file mode 100644
index 0000000..c478b58
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   Iter1
+//   find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 3, 5, 7};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ib),
+                              forward_iterator<const int*>(ib + sb)) ==
+                              input_iterator<const int*>(ia+1));
+    int ic[] = {7};
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic + 1)) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic)) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic+1)) ==
+                              input_iterator<const int*>(ia));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
new file mode 100644
index 0000000..7f82624
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2, 
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter1
+//   find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 3, 5, 7};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ib),
+                              forward_iterator<const int*>(ib + sb),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+1));
+    int ic[] = {7};
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic + 1),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic+1),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
new file mode 100644
index 0000000..13fdaca
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T> 
+//   requires HasEqualTo<Iter::value_type, T> 
+//   Iter
+//   find(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
+                                             input_iterator<const int*>(ia+s), 3);
+    assert(*r == 3);
+    r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
new file mode 100644
index 0000000..fb46d14
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter
+//   find_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
+                                                input_iterator<const int*>(ia+s),
+                                                std::bind2nd(std::equal_to<int>(), 3));
+    assert(*r == 3);
+    r = std::find_if(input_iterator<const int*>(ia),
+                     input_iterator<const int*>(ia+s),
+                     std::bind2nd(std::equal_to<int>(), 10));
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
new file mode 100644
index 0000000..6f5e754
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   Iter
+//   find_if_not(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
+                                                    input_iterator<const int*>(ia+s),
+                                                    std::bind2nd(std::not_equal_to<int>(), 3));
+    assert(*r == 3);
+    r = std::find_if_not(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia+s),
+                         std::bind2nd(std::not_equal_to<int>(), 10));
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp b/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
new file mode 100644
index 0000000..57a9abb
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Callable<auto, Iter::reference> Function> 
+//   requires CopyConstructible<Function> 
+//   Function
+//   for_each(Iter first, Iter last, Function f);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct for_each_test
+{
+    for_each_test(int c) : count(c) {}
+    int count;
+    void operator()(int& i) {++i; ++count;}
+};
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    for_each_test f = std::for_each(input_iterator<int*>(ia),
+                                    input_iterator<int*>(ia+s),
+                                    for_each_test(0));
+    assert(f.count == s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ia[i] == i+1);
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
new file mode 100644
index 0000000..fec6429
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
@@ -0,0 +1,325 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2>
+//   bool
+//   is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+//                  ForwardIterator2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        const int ia[] = {0};
+        const int ib[] = {0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + 0),
+                                   forward_iterator<const int*>(ib)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0};
+        const int ib[] = {1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+    }
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
new file mode 100644
index 0000000..c202793
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
@@ -0,0 +1,364 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+//   bool
+//   is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+//                  ForwardIterator2 first2, BinaryPredicate pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        const int ia[] = {0};
+        const int ib[] = {0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + 0),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0};
+        const int ib[] = {1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+    }
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp b/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
new file mode 100644
index 0000000..a4c9715
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   none_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {1, 3, 5, 7};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp b/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
new file mode 100644
index 0000000..b731281
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   Iter1
+//   search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2)) == Iter1(ia+1));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+    assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa)) == Iter1(ia+sa-1));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa)) == Iter1(ia+sa-3));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+sa-1));
+    assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+1));
+    int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1)) == Iter1(ib+1));
+    int id[] = {1, 2};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2)) == Iter1(ib+1));
+    int ie[] = {1, 2, 3};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3)) == Iter1(ib+4));
+    int ig[] = {1, 2, 3, 4};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4)) == Iter1(ib+8));
+    int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int ii[] = {1, 1, 2};
+    assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3)) == Iter1(ih+3));
+    int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+    const unsigned sj = sizeof(ij)/sizeof(ij[0]);
+    int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+    const unsigned sk = sizeof(ik)/sizeof(ik[0]);
+    assert(std::search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk)) == Iter1(ij+6));
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp b/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
new file mode 100644
index 0000000..a8353e8
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   Iter1
+//   search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), count_equal()) == Iter1(ia+1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-3));
+    assert(count_equal::count <= sa*3);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= sa*sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= (sa-1)*sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), count_equal()) == Iter1(ib+1));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    int id[] = {1, 2};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), count_equal()) == Iter1(ib+1));
+    assert(count_equal::count <= sb*2);
+    count_equal::count = 0;
+    int ie[] = {1, 2, 3};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), count_equal()) == Iter1(ib+4));
+    assert(count_equal::count <= sb*3);
+    count_equal::count = 0;
+    int ig[] = {1, 2, 3, 4};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), count_equal()) == Iter1(ib+8));
+    assert(count_equal::count <= sb*4);
+    count_equal::count = 0;
+    int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int ii[] = {1, 1, 2};
+    assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), count_equal()) == Iter1(ih+3));
+    assert(count_equal::count <= sh*3);
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
new file mode 100644
index 0000000..aedbd4f
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2> 
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type> 
+//   pair<Iter1, Iter2>
+//   mismatch(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib)) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+}
diff --git a/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
new file mode 100644
index 0000000..2705ca2
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, 
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred> 
+//   requires CopyConstructible<Pred> 
+//   pair<Iter1, Iter2>
+//   mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib),
+                         std::equal_to<int>()) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+    assert(std::mismatch(ia, ia + sa, ib, std::equal_to<int>()) ==
+           (std::pair<int*,int*>(ia+3,ib+3)));
+}
diff --git a/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp b/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
new file mode 100644
index 0000000..ba6c8a2
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires HasLess<T, Iter::value_type> 
+//         && HasLess<Iter::value_type, T> 
+//   bool
+//   binary_search(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+    assert(std::binary_search(first, last, value) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x < M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+    test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+    test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+    int d[] = {0, 2, 4, 6};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 7; ++x)
+            test(d, e, x, (x % 2 == 0) && ((e-d)*2 > x));
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
new file mode 100644
index 0000000..0001812
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare> 
+//   requires Predicate<Compare, T, Iter::value_type> 
+//         && Predicate<Compare, Iter::value_type, T> 
+//   bool
+//   binary_search(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+    assert(std::binary_search(first, last, value, std::greater<int>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x < M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+    test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+    test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+    int d[] = {6, 4, 2, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 7; ++x)
+            test(d, e, x, (x % 2 == 0) && e != d && (-2*(e-d) + 8 <= x));
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp
new file mode 100644
index 0000000..9cf34cd
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires HasLess<T, Iter::value_type> 
+//         && HasLess<Iter::value_type, T> 
+//   pair<Iter, Iter> 
+//   equal_range(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    std::pair<Iter, Iter> i = std::equal_range(first, last, value);
+    for (Iter j = first; j != i.first; ++j)
+        assert(*j < value);
+    for (Iter j = i.first; j != last; ++j)
+        assert(!(*j < value));
+    for (Iter j = first; j != i.second; ++j)
+        assert(!(value < *j));
+    for (Iter j = i.second; j != last; ++j)
+        assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
new file mode 100644
index 0000000..54b2d8f
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare> 
+//   requires Predicate<Compare, T, Iter::value_type> 
+//         && Predicate<Compare, Iter::value_type, T> 
+//   pair<Iter, Iter> 
+//   equal_range(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    std::pair<Iter, Iter> i = std::equal_range(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i.first; ++j)
+        assert(std::greater<int>()(*j, value));
+    for (Iter j = i.first; j != last; ++j)
+        assert(!std::greater<int>()(*j, value));
+    for (Iter j = first; j != i.second; ++j)
+        assert(!std::greater<int>()(value, *j));
+    for (Iter j = i.second; j != last; ++j)
+        assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
new file mode 100644
index 0000000..b0c5bef
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires HasLess<Iter::value_type, T> 
+//   Iter
+//   lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::lower_bound(first, last, value);
+    for (Iter j = first; j != i; ++j)
+        assert(*j < value);
+    for (Iter j = i; j != last; ++j)
+        assert(!(*j < value));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
new file mode 100644
index 0000000..795d314
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires HasLess<Iter::value_type, T> 
+//   Iter
+//   lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::lower_bound(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i; ++j)
+        assert(std::greater<int>()(*j, value));
+    for (Iter j = i; j != last; ++j)
+        assert(!std::greater<int>()(*j, value));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
new file mode 100644
index 0000000..25e1c3e
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T> 
+//   requires HasLess<T, Iter::value_type> 
+//   Iter
+//   upper_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::upper_bound(first, last, value);
+    for (Iter j = first; j != i; ++j)
+        assert(!(value < *j));
+    for (Iter j = i; j != last; ++j)
+        assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp b/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
new file mode 100644
index 0000000..5dcb050
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, Predicate<auto, T, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   Iter
+//   upper_bound(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::upper_bound(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i; ++j)
+        assert(!std::greater<int>()(value, *j));
+    for (Iter j = i; j != last; ++j)
+        assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
new file mode 100644
index 0000000..69b9447
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   bool
+//   is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap(i1, i1));
+    assert(std::is_heap(i1, i1+1) == (std::is_heap_until(i1, i1+1) == i1+1));
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap(i1, i1+2) == (std::is_heap_until(i1, i1+2) == i1+2));
+    assert(std::is_heap(i2, i2+2) == (std::is_heap_until(i2, i2+2) == i2+2));
+    assert(std::is_heap(i3, i3+2) == (std::is_heap_until(i3, i3+2) == i3+2));
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap(i4, i4+3) == (std::is_heap_until(i4, i4+3) == i4+3));
+    assert(std::is_heap(i5, i5+3) == (std::is_heap_until(i5, i5+3) == i5+3));
+    assert(std::is_heap(i6, i6+3) == (std::is_heap_until(i6, i6+3) == i6+3));
+    assert(std::is_heap(i7, i7+3) == (std::is_heap_until(i7, i7+3) == i7+3));
+    assert(std::is_heap(i8, i8+3) == (std::is_heap_until(i8, i8+3) == i8+3));
+    assert(std::is_heap(i9, i9+3) == (std::is_heap_until(i9, i9+3) == i9+3));
+    assert(std::is_heap(i10, i10+3) == (std::is_heap_until(i10, i10+3) == i10+3));
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap(i11, i11+4) == (std::is_heap_until(i11, i11+4) == i11+4));
+    assert(std::is_heap(i12, i12+4) == (std::is_heap_until(i12, i12+4) == i12+4));
+    assert(std::is_heap(i13, i13+4) == (std::is_heap_until(i13, i13+4) == i13+4));
+    assert(std::is_heap(i14, i14+4) == (std::is_heap_until(i14, i14+4) == i14+4));
+    assert(std::is_heap(i15, i15+4) == (std::is_heap_until(i15, i15+4) == i15+4));
+    assert(std::is_heap(i16, i16+4) == (std::is_heap_until(i16, i16+4) == i16+4));
+    assert(std::is_heap(i17, i17+4) == (std::is_heap_until(i17, i17+4) == i17+4));
+    assert(std::is_heap(i18, i18+4) == (std::is_heap_until(i18, i18+4) == i18+4));
+    assert(std::is_heap(i19, i19+4) == (std::is_heap_until(i19, i19+4) == i19+4));
+    assert(std::is_heap(i20, i20+4) == (std::is_heap_until(i20, i20+4) == i20+4));
+    assert(std::is_heap(i21, i21+4) == (std::is_heap_until(i21, i21+4) == i21+4));
+    assert(std::is_heap(i22, i22+4) == (std::is_heap_until(i22, i22+4) == i22+4));
+    assert(std::is_heap(i23, i23+4) == (std::is_heap_until(i23, i23+4) == i23+4));
+    assert(std::is_heap(i24, i24+4) == (std::is_heap_until(i24, i24+4) == i24+4));
+    assert(std::is_heap(i25, i25+4) == (std::is_heap_until(i25, i25+4) == i25+4));
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap(i26, i26+5) == (std::is_heap_until(i26, i26+5) == i26+5));
+    assert(std::is_heap(i27, i27+5) == (std::is_heap_until(i27, i27+5) == i27+5));
+    assert(std::is_heap(i28, i28+5) == (std::is_heap_until(i28, i28+5) == i28+5));
+    assert(std::is_heap(i29, i29+5) == (std::is_heap_until(i29, i29+5) == i29+5));
+    assert(std::is_heap(i30, i30+5) == (std::is_heap_until(i30, i30+5) == i30+5));
+    assert(std::is_heap(i31, i31+5) == (std::is_heap_until(i31, i31+5) == i31+5));
+    assert(std::is_heap(i32, i32+5) == (std::is_heap_until(i32, i32+5) == i32+5));
+    assert(std::is_heap(i33, i33+5) == (std::is_heap_until(i33, i33+5) == i33+5));
+    assert(std::is_heap(i34, i34+5) == (std::is_heap_until(i34, i34+5) == i34+5));
+    assert(std::is_heap(i35, i35+5) == (std::is_heap_until(i35, i35+5) == i35+5));
+    assert(std::is_heap(i36, i36+5) == (std::is_heap_until(i36, i36+5) == i36+5));
+    assert(std::is_heap(i37, i37+5) == (std::is_heap_until(i37, i37+5) == i37+5));
+    assert(std::is_heap(i38, i38+5) == (std::is_heap_until(i38, i38+5) == i38+5));
+    assert(std::is_heap(i39, i39+5) == (std::is_heap_until(i39, i39+5) == i39+5));
+    assert(std::is_heap(i40, i40+5) == (std::is_heap_until(i40, i40+5) == i40+5));
+    assert(std::is_heap(i41, i41+5) == (std::is_heap_until(i41, i41+5) == i41+5));
+    assert(std::is_heap(i42, i42+5) == (std::is_heap_until(i42, i42+5) == i42+5));
+    assert(std::is_heap(i43, i43+5) == (std::is_heap_until(i43, i43+5) == i43+5));
+    assert(std::is_heap(i44, i44+5) == (std::is_heap_until(i44, i44+5) == i44+5));
+    assert(std::is_heap(i45, i45+5) == (std::is_heap_until(i45, i45+5) == i45+5));
+    assert(std::is_heap(i46, i46+5) == (std::is_heap_until(i46, i46+5) == i46+5));
+    assert(std::is_heap(i47, i47+5) == (std::is_heap_until(i47, i47+5) == i47+5));
+    assert(std::is_heap(i48, i48+5) == (std::is_heap_until(i48, i48+5) == i48+5));
+    assert(std::is_heap(i49, i49+5) == (std::is_heap_until(i49, i49+5) == i49+5));
+    assert(std::is_heap(i50, i50+5) == (std::is_heap_until(i50, i50+5) == i50+5));
+    assert(std::is_heap(i51, i51+5) == (std::is_heap_until(i51, i51+5) == i51+5));
+    assert(std::is_heap(i52, i52+5) == (std::is_heap_until(i52, i52+5) == i52+5));
+    assert(std::is_heap(i53, i53+5) == (std::is_heap_until(i53, i53+5) == i53+5));
+    assert(std::is_heap(i54, i54+5) == (std::is_heap_until(i54, i54+5) == i54+5));
+    assert(std::is_heap(i55, i55+5) == (std::is_heap_until(i55, i55+5) == i55+5));
+    assert(std::is_heap(i56, i56+5) == (std::is_heap_until(i56, i56+5) == i56+5));
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i57, i57+6) == (std::is_heap_until(i57, i57+6) == i57+6));
+    assert(std::is_heap(i58, i58+6) == (std::is_heap_until(i58, i58+6) == i58+6));
+    assert(std::is_heap(i59, i59+6) == (std::is_heap_until(i59, i59+6) == i59+6));
+    assert(std::is_heap(i60, i60+6) == (std::is_heap_until(i60, i60+6) == i60+6));
+    assert(std::is_heap(i61, i61+6) == (std::is_heap_until(i61, i61+6) == i61+6));
+    assert(std::is_heap(i62, i62+6) == (std::is_heap_until(i62, i62+6) == i62+6));
+    assert(std::is_heap(i63, i63+6) == (std::is_heap_until(i63, i63+6) == i63+6));
+    assert(std::is_heap(i64, i64+6) == (std::is_heap_until(i64, i64+6) == i64+6));
+    assert(std::is_heap(i65, i65+6) == (std::is_heap_until(i65, i65+6) == i65+6));
+    assert(std::is_heap(i66, i66+6) == (std::is_heap_until(i66, i66+6) == i66+6));
+    assert(std::is_heap(i67, i67+6) == (std::is_heap_until(i67, i67+6) == i67+6));
+    assert(std::is_heap(i68, i68+6) == (std::is_heap_until(i68, i68+6) == i68+6));
+    assert(std::is_heap(i69, i69+6) == (std::is_heap_until(i69, i69+6) == i69+6));
+    assert(std::is_heap(i70, i70+6) == (std::is_heap_until(i70, i70+6) == i70+6));
+    assert(std::is_heap(i71, i71+6) == (std::is_heap_until(i71, i71+6) == i71+6));
+    assert(std::is_heap(i72, i72+6) == (std::is_heap_until(i72, i72+6) == i72+6));
+    assert(std::is_heap(i73, i73+6) == (std::is_heap_until(i73, i73+6) == i73+6));
+    assert(std::is_heap(i74, i74+6) == (std::is_heap_until(i74, i74+6) == i74+6));
+    assert(std::is_heap(i75, i75+6) == (std::is_heap_until(i75, i75+6) == i75+6));
+    assert(std::is_heap(i76, i76+6) == (std::is_heap_until(i76, i76+6) == i76+6));
+    assert(std::is_heap(i77, i77+6) == (std::is_heap_until(i77, i77+6) == i77+6));
+    assert(std::is_heap(i78, i78+6) == (std::is_heap_until(i78, i78+6) == i78+6));
+    assert(std::is_heap(i79, i79+6) == (std::is_heap_until(i79, i79+6) == i79+6));
+    assert(std::is_heap(i80, i80+6) == (std::is_heap_until(i80, i80+6) == i80+6));
+    assert(std::is_heap(i81, i81+6) == (std::is_heap_until(i81, i81+6) == i81+6));
+    assert(std::is_heap(i82, i82+6) == (std::is_heap_until(i82, i82+6) == i82+6));
+    assert(std::is_heap(i83, i83+6) == (std::is_heap_until(i83, i83+6) == i83+6));
+    assert(std::is_heap(i84, i84+6) == (std::is_heap_until(i84, i84+6) == i84+6));
+    assert(std::is_heap(i85, i85+6) == (std::is_heap_until(i85, i85+6) == i85+6));
+    assert(std::is_heap(i86, i86+6) == (std::is_heap_until(i86, i86+6) == i86+6));
+    assert(std::is_heap(i87, i87+6) == (std::is_heap_until(i87, i87+6) == i87+6));
+    assert(std::is_heap(i88, i88+6) == (std::is_heap_until(i88, i88+6) == i88+6));
+    assert(std::is_heap(i89, i89+6) == (std::is_heap_until(i89, i89+6) == i89+6));
+    assert(std::is_heap(i90, i90+6) == (std::is_heap_until(i90, i90+6) == i90+6));
+    assert(std::is_heap(i91, i91+6) == (std::is_heap_until(i91, i91+6) == i91+6));
+    assert(std::is_heap(i92, i92+6) == (std::is_heap_until(i92, i92+6) == i92+6));
+    assert(std::is_heap(i93, i93+6) == (std::is_heap_until(i93, i93+6) == i93+6));
+    assert(std::is_heap(i94, i94+6) == (std::is_heap_until(i94, i94+6) == i94+6));
+    assert(std::is_heap(i95, i95+6) == (std::is_heap_until(i95, i95+6) == i95+6));
+    assert(std::is_heap(i96, i96+6) == (std::is_heap_until(i96, i96+6) == i96+6));
+    assert(std::is_heap(i97, i97+6) == (std::is_heap_until(i97, i97+6) == i97+6));
+    assert(std::is_heap(i98, i98+6) == (std::is_heap_until(i98, i98+6) == i98+6));
+    assert(std::is_heap(i99, i99+6) == (std::is_heap_until(i99, i99+6) == i99+6));
+    assert(std::is_heap(i100, i100+6) == (std::is_heap_until(i100, i100+6) == i100+6));
+    assert(std::is_heap(i101, i101+6) == (std::is_heap_until(i101, i101+6) == i101+6));
+    assert(std::is_heap(i102, i102+6) == (std::is_heap_until(i102, i102+6) == i102+6));
+    assert(std::is_heap(i103, i103+6) == (std::is_heap_until(i103, i103+6) == i103+6));
+    assert(std::is_heap(i104, i104+6) == (std::is_heap_until(i104, i104+6) == i104+6));
+    assert(std::is_heap(i105, i105+6) == (std::is_heap_until(i105, i105+6) == i105+6));
+    assert(std::is_heap(i106, i106+6) == (std::is_heap_until(i106, i106+6) == i106+6));
+    assert(std::is_heap(i107, i107+6) == (std::is_heap_until(i107, i107+6) == i107+6));
+    assert(std::is_heap(i108, i108+6) == (std::is_heap_until(i108, i108+6) == i108+6));
+    assert(std::is_heap(i109, i109+6) == (std::is_heap_until(i109, i109+6) == i109+6));
+    assert(std::is_heap(i110, i110+6) == (std::is_heap_until(i110, i110+6) == i110+6));
+    assert(std::is_heap(i111, i111+6) == (std::is_heap_until(i111, i111+6) == i111+6));
+    assert(std::is_heap(i112, i112+6) == (std::is_heap_until(i112, i112+6) == i112+6));
+    assert(std::is_heap(i113, i113+6) == (std::is_heap_until(i113, i113+6) == i113+6));
+    assert(std::is_heap(i114, i114+6) == (std::is_heap_until(i114, i114+6) == i114+6));
+    assert(std::is_heap(i115, i115+6) == (std::is_heap_until(i115, i115+6) == i115+6));
+    assert(std::is_heap(i116, i116+6) == (std::is_heap_until(i116, i116+6) == i116+6));
+    assert(std::is_heap(i117, i117+6) == (std::is_heap_until(i117, i117+6) == i117+6));
+    assert(std::is_heap(i118, i118+6) == (std::is_heap_until(i118, i118+6) == i118+6));
+    assert(std::is_heap(i119, i119+6) == (std::is_heap_until(i119, i119+6) == i119+6));
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i120, i120+7) == (std::is_heap_until(i120, i120+7) == i120+7));
+    assert(std::is_heap(i121, i121+7) == (std::is_heap_until(i121, i121+7) == i121+7));
+    assert(std::is_heap(i122, i122+7) == (std::is_heap_until(i122, i122+7) == i122+7));
+    assert(std::is_heap(i123, i123+7) == (std::is_heap_until(i123, i123+7) == i123+7));
+    assert(std::is_heap(i124, i124+7) == (std::is_heap_until(i124, i124+7) == i124+7));
+    assert(std::is_heap(i125, i125+7) == (std::is_heap_until(i125, i125+7) == i125+7));
+    assert(std::is_heap(i126, i126+7) == (std::is_heap_until(i126, i126+7) == i126+7));
+    assert(std::is_heap(i127, i127+7) == (std::is_heap_until(i127, i127+7) == i127+7));
+    assert(std::is_heap(i128, i128+7) == (std::is_heap_until(i128, i128+7) == i128+7));
+    assert(std::is_heap(i129, i129+7) == (std::is_heap_until(i129, i129+7) == i129+7));
+    assert(std::is_heap(i130, i130+7) == (std::is_heap_until(i130, i130+7) == i130+7));
+    assert(std::is_heap(i131, i131+7) == (std::is_heap_until(i131, i131+7) == i131+7));
+    assert(std::is_heap(i132, i132+7) == (std::is_heap_until(i132, i132+7) == i132+7));
+    assert(std::is_heap(i133, i133+7) == (std::is_heap_until(i133, i133+7) == i133+7));
+    assert(std::is_heap(i134, i134+7) == (std::is_heap_until(i134, i134+7) == i134+7));
+    assert(std::is_heap(i135, i135+7) == (std::is_heap_until(i135, i135+7) == i135+7));
+    assert(std::is_heap(i136, i136+7) == (std::is_heap_until(i136, i136+7) == i136+7));
+    assert(std::is_heap(i137, i137+7) == (std::is_heap_until(i137, i137+7) == i137+7));
+    assert(std::is_heap(i138, i138+7) == (std::is_heap_until(i138, i138+7) == i138+7));
+    assert(std::is_heap(i139, i139+7) == (std::is_heap_until(i139, i139+7) == i139+7));
+    assert(std::is_heap(i140, i140+7) == (std::is_heap_until(i140, i140+7) == i140+7));
+    assert(std::is_heap(i141, i141+7) == (std::is_heap_until(i141, i141+7) == i141+7));
+    assert(std::is_heap(i142, i142+7) == (std::is_heap_until(i142, i142+7) == i142+7));
+    assert(std::is_heap(i143, i143+7) == (std::is_heap_until(i143, i143+7) == i143+7));
+    assert(std::is_heap(i144, i144+7) == (std::is_heap_until(i144, i144+7) == i144+7));
+    assert(std::is_heap(i145, i145+7) == (std::is_heap_until(i145, i145+7) == i145+7));
+    assert(std::is_heap(i146, i146+7) == (std::is_heap_until(i146, i146+7) == i146+7));
+    assert(std::is_heap(i147, i147+7) == (std::is_heap_until(i147, i147+7) == i147+7));
+    assert(std::is_heap(i148, i148+7) == (std::is_heap_until(i148, i148+7) == i148+7));
+    assert(std::is_heap(i149, i149+7) == (std::is_heap_until(i149, i149+7) == i149+7));
+    assert(std::is_heap(i150, i150+7) == (std::is_heap_until(i150, i150+7) == i150+7));
+    assert(std::is_heap(i151, i151+7) == (std::is_heap_until(i151, i151+7) == i151+7));
+    assert(std::is_heap(i152, i152+7) == (std::is_heap_until(i152, i152+7) == i152+7));
+    assert(std::is_heap(i153, i153+7) == (std::is_heap_until(i153, i153+7) == i153+7));
+    assert(std::is_heap(i154, i154+7) == (std::is_heap_until(i154, i154+7) == i154+7));
+    assert(std::is_heap(i155, i155+7) == (std::is_heap_until(i155, i155+7) == i155+7));
+    assert(std::is_heap(i156, i156+7) == (std::is_heap_until(i156, i156+7) == i156+7));
+    assert(std::is_heap(i157, i157+7) == (std::is_heap_until(i157, i157+7) == i157+7));
+    assert(std::is_heap(i158, i158+7) == (std::is_heap_until(i158, i158+7) == i158+7));
+    assert(std::is_heap(i159, i159+7) == (std::is_heap_until(i159, i159+7) == i159+7));
+    assert(std::is_heap(i160, i160+7) == (std::is_heap_until(i160, i160+7) == i160+7));
+    assert(std::is_heap(i161, i161+7) == (std::is_heap_until(i161, i161+7) == i161+7));
+    assert(std::is_heap(i162, i162+7) == (std::is_heap_until(i162, i162+7) == i162+7));
+    assert(std::is_heap(i163, i163+7) == (std::is_heap_until(i163, i163+7) == i163+7));
+    assert(std::is_heap(i164, i164+7) == (std::is_heap_until(i164, i164+7) == i164+7));
+    assert(std::is_heap(i165, i165+7) == (std::is_heap_until(i165, i165+7) == i165+7));
+    assert(std::is_heap(i166, i166+7) == (std::is_heap_until(i166, i166+7) == i166+7));
+    assert(std::is_heap(i167, i167+7) == (std::is_heap_until(i167, i167+7) == i167+7));
+    assert(std::is_heap(i168, i168+7) == (std::is_heap_until(i168, i168+7) == i168+7));
+    assert(std::is_heap(i169, i169+7) == (std::is_heap_until(i169, i169+7) == i169+7));
+    assert(std::is_heap(i170, i170+7) == (std::is_heap_until(i170, i170+7) == i170+7));
+    assert(std::is_heap(i171, i171+7) == (std::is_heap_until(i171, i171+7) == i171+7));
+    assert(std::is_heap(i172, i172+7) == (std::is_heap_until(i172, i172+7) == i172+7));
+    assert(std::is_heap(i173, i173+7) == (std::is_heap_until(i173, i173+7) == i173+7));
+    assert(std::is_heap(i174, i174+7) == (std::is_heap_until(i174, i174+7) == i174+7));
+    assert(std::is_heap(i175, i175+7) == (std::is_heap_until(i175, i175+7) == i175+7));
+    assert(std::is_heap(i176, i176+7) == (std::is_heap_until(i176, i176+7) == i176+7));
+    assert(std::is_heap(i177, i177+7) == (std::is_heap_until(i177, i177+7) == i177+7));
+    assert(std::is_heap(i178, i178+7) == (std::is_heap_until(i178, i178+7) == i178+7));
+    assert(std::is_heap(i179, i179+7) == (std::is_heap_until(i179, i179+7) == i179+7));
+    assert(std::is_heap(i180, i180+7) == (std::is_heap_until(i180, i180+7) == i180+7));
+    assert(std::is_heap(i181, i181+7) == (std::is_heap_until(i181, i181+7) == i181+7));
+    assert(std::is_heap(i182, i182+7) == (std::is_heap_until(i182, i182+7) == i182+7));
+    assert(std::is_heap(i183, i183+7) == (std::is_heap_until(i183, i183+7) == i183+7));
+    assert(std::is_heap(i184, i184+7) == (std::is_heap_until(i184, i184+7) == i184+7));
+    assert(std::is_heap(i185, i185+7) == (std::is_heap_until(i185, i185+7) == i185+7));
+    assert(std::is_heap(i186, i186+7) == (std::is_heap_until(i186, i186+7) == i186+7));
+    assert(std::is_heap(i187, i187+7) == (std::is_heap_until(i187, i187+7) == i187+7));
+    assert(std::is_heap(i188, i188+7) == (std::is_heap_until(i188, i188+7) == i188+7));
+    assert(std::is_heap(i189, i189+7) == (std::is_heap_until(i189, i189+7) == i189+7));
+    assert(std::is_heap(i190, i190+7) == (std::is_heap_until(i190, i190+7) == i190+7));
+    assert(std::is_heap(i191, i191+7) == (std::is_heap_until(i191, i191+7) == i191+7));
+    assert(std::is_heap(i192, i192+7) == (std::is_heap_until(i192, i192+7) == i192+7));
+    assert(std::is_heap(i193, i193+7) == (std::is_heap_until(i193, i193+7) == i193+7));
+    assert(std::is_heap(i194, i194+7) == (std::is_heap_until(i194, i194+7) == i194+7));
+    assert(std::is_heap(i195, i195+7) == (std::is_heap_until(i195, i195+7) == i195+7));
+    assert(std::is_heap(i196, i196+7) == (std::is_heap_until(i196, i196+7) == i196+7));
+    assert(std::is_heap(i197, i197+7) == (std::is_heap_until(i197, i197+7) == i197+7));
+    assert(std::is_heap(i198, i198+7) == (std::is_heap_until(i198, i198+7) == i198+7));
+    assert(std::is_heap(i199, i199+7) == (std::is_heap_until(i199, i199+7) == i199+7));
+    assert(std::is_heap(i200, i200+7) == (std::is_heap_until(i200, i200+7) == i200+7));
+    assert(std::is_heap(i201, i201+7) == (std::is_heap_until(i201, i201+7) == i201+7));
+    assert(std::is_heap(i202, i202+7) == (std::is_heap_until(i202, i202+7) == i202+7));
+    assert(std::is_heap(i203, i203+7) == (std::is_heap_until(i203, i203+7) == i203+7));
+    assert(std::is_heap(i204, i204+7) == (std::is_heap_until(i204, i204+7) == i204+7));
+    assert(std::is_heap(i205, i205+7) == (std::is_heap_until(i205, i205+7) == i205+7));
+    assert(std::is_heap(i206, i206+7) == (std::is_heap_until(i206, i206+7) == i206+7));
+    assert(std::is_heap(i207, i207+7) == (std::is_heap_until(i207, i207+7) == i207+7));
+    assert(std::is_heap(i208, i208+7) == (std::is_heap_until(i208, i208+7) == i208+7));
+    assert(std::is_heap(i209, i209+7) == (std::is_heap_until(i209, i209+7) == i209+7));
+    assert(std::is_heap(i210, i210+7) == (std::is_heap_until(i210, i210+7) == i210+7));
+    assert(std::is_heap(i211, i211+7) == (std::is_heap_until(i211, i211+7) == i211+7));
+    assert(std::is_heap(i212, i212+7) == (std::is_heap_until(i212, i212+7) == i212+7));
+    assert(std::is_heap(i213, i213+7) == (std::is_heap_until(i213, i213+7) == i213+7));
+    assert(std::is_heap(i214, i214+7) == (std::is_heap_until(i214, i214+7) == i214+7));
+    assert(std::is_heap(i215, i215+7) == (std::is_heap_until(i215, i215+7) == i215+7));
+    assert(std::is_heap(i216, i216+7) == (std::is_heap_until(i216, i216+7) == i216+7));
+    assert(std::is_heap(i217, i217+7) == (std::is_heap_until(i217, i217+7) == i217+7));
+    assert(std::is_heap(i218, i218+7) == (std::is_heap_until(i218, i218+7) == i218+7));
+    assert(std::is_heap(i219, i219+7) == (std::is_heap_until(i219, i219+7) == i219+7));
+    assert(std::is_heap(i220, i220+7) == (std::is_heap_until(i220, i220+7) == i220+7));
+    assert(std::is_heap(i221, i221+7) == (std::is_heap_until(i221, i221+7) == i221+7));
+    assert(std::is_heap(i222, i222+7) == (std::is_heap_until(i222, i222+7) == i222+7));
+    assert(std::is_heap(i223, i223+7) == (std::is_heap_until(i223, i223+7) == i223+7));
+    assert(std::is_heap(i224, i224+7) == (std::is_heap_until(i224, i224+7) == i224+7));
+    assert(std::is_heap(i225, i225+7) == (std::is_heap_until(i225, i225+7) == i225+7));
+    assert(std::is_heap(i226, i226+7) == (std::is_heap_until(i226, i226+7) == i226+7));
+    assert(std::is_heap(i227, i227+7) == (std::is_heap_until(i227, i227+7) == i227+7));
+    assert(std::is_heap(i228, i228+7) == (std::is_heap_until(i228, i228+7) == i228+7));
+    assert(std::is_heap(i229, i229+7) == (std::is_heap_until(i229, i229+7) == i229+7));
+    assert(std::is_heap(i230, i230+7) == (std::is_heap_until(i230, i230+7) == i230+7));
+    assert(std::is_heap(i231, i231+7) == (std::is_heap_until(i231, i231+7) == i231+7));
+    assert(std::is_heap(i232, i232+7) == (std::is_heap_until(i232, i232+7) == i232+7));
+    assert(std::is_heap(i233, i233+7) == (std::is_heap_until(i233, i233+7) == i233+7));
+    assert(std::is_heap(i234, i234+7) == (std::is_heap_until(i234, i234+7) == i234+7));
+    assert(std::is_heap(i235, i235+7) == (std::is_heap_until(i235, i235+7) == i235+7));
+    assert(std::is_heap(i236, i236+7) == (std::is_heap_until(i236, i236+7) == i236+7));
+    assert(std::is_heap(i237, i237+7) == (std::is_heap_until(i237, i237+7) == i237+7));
+    assert(std::is_heap(i238, i238+7) == (std::is_heap_until(i238, i238+7) == i238+7));
+    assert(std::is_heap(i239, i239+7) == (std::is_heap_until(i239, i239+7) == i239+7));
+    assert(std::is_heap(i240, i240+7) == (std::is_heap_until(i240, i240+7) == i240+7));
+    assert(std::is_heap(i241, i241+7) == (std::is_heap_until(i241, i241+7) == i241+7));
+    assert(std::is_heap(i242, i242+7) == (std::is_heap_until(i242, i242+7) == i242+7));
+    assert(std::is_heap(i243, i243+7) == (std::is_heap_until(i243, i243+7) == i243+7));
+    assert(std::is_heap(i244, i244+7) == (std::is_heap_until(i244, i244+7) == i244+7));
+    assert(std::is_heap(i245, i245+7) == (std::is_heap_until(i245, i245+7) == i245+7));
+    assert(std::is_heap(i246, i246+7) == (std::is_heap_until(i246, i246+7) == i246+7));
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
new file mode 100644
index 0000000..6b0609d
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
@@ -0,0 +1,523 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   bool
+//   is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap(i1, i1, std::greater<int>()));
+    assert(std::is_heap(i1, i1+1, std::greater<int>()) == (std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1));
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap(i1, i1+2, std::greater<int>()) == (std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2));
+    assert(std::is_heap(i2, i2+2, std::greater<int>()) == (std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2));
+    assert(std::is_heap(i3, i3+2, std::greater<int>()) == (std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+2));
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap(i4, i4+3, std::greater<int>()) == (std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3));
+    assert(std::is_heap(i5, i5+3, std::greater<int>()) == (std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3));
+    assert(std::is_heap(i6, i6+3, std::greater<int>()) == (std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3));
+    assert(std::is_heap(i7, i7+3, std::greater<int>()) == (std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3));
+    assert(std::is_heap(i8, i8+3, std::greater<int>()) == (std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+3));
+    assert(std::is_heap(i9, i9+3, std::greater<int>()) == (std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+3));
+    assert(std::is_heap(i10, i10+3, std::greater<int>()) == (std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+3));
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap(i11, i11+4, std::greater<int>()) == (std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4));
+    assert(std::is_heap(i12, i12+4, std::greater<int>()) == (std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4));
+    assert(std::is_heap(i13, i13+4, std::greater<int>()) == (std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4));
+    assert(std::is_heap(i14, i14+4, std::greater<int>()) == (std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4));
+    assert(std::is_heap(i15, i15+4, std::greater<int>()) == (std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+4));
+    assert(std::is_heap(i16, i16+4, std::greater<int>()) == (std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4));
+    assert(std::is_heap(i17, i17+4, std::greater<int>()) == (std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+4));
+    assert(std::is_heap(i18, i18+4, std::greater<int>()) == (std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4));
+    assert(std::is_heap(i19, i19+4, std::greater<int>()) == (std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+4));
+    assert(std::is_heap(i20, i20+4, std::greater<int>()) == (std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+4));
+    assert(std::is_heap(i21, i21+4, std::greater<int>()) == (std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+4));
+    assert(std::is_heap(i22, i22+4, std::greater<int>()) == (std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+4));
+    assert(std::is_heap(i23, i23+4, std::greater<int>()) == (std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+4));
+    assert(std::is_heap(i24, i24+4, std::greater<int>()) == (std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+4));
+    assert(std::is_heap(i25, i25+4, std::greater<int>()) == (std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+4));
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap(i26, i26+5, std::greater<int>()) == (std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5));
+    assert(std::is_heap(i27, i27+5, std::greater<int>()) == (std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5));
+    assert(std::is_heap(i28, i28+5, std::greater<int>()) == (std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5));
+    assert(std::is_heap(i29, i29+5, std::greater<int>()) == (std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5));
+    assert(std::is_heap(i30, i30+5, std::greater<int>()) == (std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5));
+    assert(std::is_heap(i31, i31+5, std::greater<int>()) == (std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5));
+    assert(std::is_heap(i32, i32+5, std::greater<int>()) == (std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5));
+    assert(std::is_heap(i33, i33+5, std::greater<int>()) == (std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5));
+    assert(std::is_heap(i34, i34+5, std::greater<int>()) == (std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+5));
+    assert(std::is_heap(i35, i35+5, std::greater<int>()) == (std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+5));
+    assert(std::is_heap(i36, i36+5, std::greater<int>()) == (std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+5));
+    assert(std::is_heap(i37, i37+5, std::greater<int>()) == (std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5));
+    assert(std::is_heap(i38, i38+5, std::greater<int>()) == (std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+5));
+    assert(std::is_heap(i39, i39+5, std::greater<int>()) == (std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+5));
+    assert(std::is_heap(i40, i40+5, std::greater<int>()) == (std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+5));
+    assert(std::is_heap(i41, i41+5, std::greater<int>()) == (std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5));
+    assert(std::is_heap(i42, i42+5, std::greater<int>()) == (std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+5));
+    assert(std::is_heap(i43, i43+5, std::greater<int>()) == (std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+5));
+    assert(std::is_heap(i44, i44+5, std::greater<int>()) == (std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+5));
+    assert(std::is_heap(i45, i45+5, std::greater<int>()) == (std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+5));
+    assert(std::is_heap(i46, i46+5, std::greater<int>()) == (std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+5));
+    assert(std::is_heap(i47, i47+5, std::greater<int>()) == (std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+5));
+    assert(std::is_heap(i48, i48+5, std::greater<int>()) == (std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+5));
+    assert(std::is_heap(i49, i49+5, std::greater<int>()) == (std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+5));
+    assert(std::is_heap(i50, i50+5, std::greater<int>()) == (std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+5));
+    assert(std::is_heap(i51, i51+5, std::greater<int>()) == (std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+5));
+    assert(std::is_heap(i52, i52+5, std::greater<int>()) == (std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+5));
+    assert(std::is_heap(i53, i53+5, std::greater<int>()) == (std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+5));
+    assert(std::is_heap(i54, i54+5, std::greater<int>()) == (std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+5));
+    assert(std::is_heap(i55, i55+5, std::greater<int>()) == (std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+5));
+    assert(std::is_heap(i56, i56+5, std::greater<int>()) == (std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+5));
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i57, i57+6, std::greater<int>()) == (std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6));
+    assert(std::is_heap(i58, i58+6, std::greater<int>()) == (std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6));
+    assert(std::is_heap(i59, i59+6, std::greater<int>()) == (std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6));
+    assert(std::is_heap(i60, i60+6, std::greater<int>()) == (std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6));
+    assert(std::is_heap(i61, i61+6, std::greater<int>()) == (std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6));
+    assert(std::is_heap(i62, i62+6, std::greater<int>()) == (std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6));
+    assert(std::is_heap(i63, i63+6, std::greater<int>()) == (std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6));
+    assert(std::is_heap(i64, i64+6, std::greater<int>()) == (std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6));
+    assert(std::is_heap(i65, i65+6, std::greater<int>()) == (std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+6));
+    assert(std::is_heap(i66, i66+6, std::greater<int>()) == (std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6));
+    assert(std::is_heap(i67, i67+6, std::greater<int>()) == (std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+6));
+    assert(std::is_heap(i68, i68+6, std::greater<int>()) == (std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6));
+    assert(std::is_heap(i69, i69+6, std::greater<int>()) == (std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+6));
+    assert(std::is_heap(i70, i70+6, std::greater<int>()) == (std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6));
+    assert(std::is_heap(i71, i71+6, std::greater<int>()) == (std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+6));
+    assert(std::is_heap(i72, i72+6, std::greater<int>()) == (std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6));
+    assert(std::is_heap(i73, i73+6, std::greater<int>()) == (std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+6));
+    assert(std::is_heap(i74, i74+6, std::greater<int>()) == (std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+6));
+    assert(std::is_heap(i75, i75+6, std::greater<int>()) == (std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+6));
+    assert(std::is_heap(i76, i76+6, std::greater<int>()) == (std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+6));
+    assert(std::is_heap(i77, i77+6, std::greater<int>()) == (std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+6));
+    assert(std::is_heap(i78, i78+6, std::greater<int>()) == (std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+6));
+    assert(std::is_heap(i79, i79+6, std::greater<int>()) == (std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6));
+    assert(std::is_heap(i80, i80+6, std::greater<int>()) == (std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6));
+    assert(std::is_heap(i81, i81+6, std::greater<int>()) == (std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+6));
+    assert(std::is_heap(i82, i82+6, std::greater<int>()) == (std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+6));
+    assert(std::is_heap(i83, i83+6, std::greater<int>()) == (std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+6));
+    assert(std::is_heap(i84, i84+6, std::greater<int>()) == (std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+6));
+    assert(std::is_heap(i85, i85+6, std::greater<int>()) == (std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+6));
+    assert(std::is_heap(i86, i86+6, std::greater<int>()) == (std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+6));
+    assert(std::is_heap(i87, i87+6, std::greater<int>()) == (std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+6));
+    assert(std::is_heap(i88, i88+6, std::greater<int>()) == (std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6));
+    assert(std::is_heap(i89, i89+6, std::greater<int>()) == (std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+6));
+    assert(std::is_heap(i90, i90+6, std::greater<int>()) == (std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+6));
+    assert(std::is_heap(i91, i91+6, std::greater<int>()) == (std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+6));
+    assert(std::is_heap(i92, i92+6, std::greater<int>()) == (std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+6));
+    assert(std::is_heap(i93, i93+6, std::greater<int>()) == (std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+6));
+    assert(std::is_heap(i94, i94+6, std::greater<int>()) == (std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+6));
+    assert(std::is_heap(i95, i95+6, std::greater<int>()) == (std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+6));
+    assert(std::is_heap(i96, i96+6, std::greater<int>()) == (std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+6));
+    assert(std::is_heap(i97, i97+6, std::greater<int>()) == (std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+6));
+    assert(std::is_heap(i98, i98+6, std::greater<int>()) == (std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+6));
+    assert(std::is_heap(i99, i99+6, std::greater<int>()) == (std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+6));
+    assert(std::is_heap(i100, i100+6, std::greater<int>()) == (std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+6));
+    assert(std::is_heap(i101, i101+6, std::greater<int>()) == (std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+6));
+    assert(std::is_heap(i102, i102+6, std::greater<int>()) == (std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+6));
+    assert(std::is_heap(i103, i103+6, std::greater<int>()) == (std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+6));
+    assert(std::is_heap(i104, i104+6, std::greater<int>()) == (std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+6));
+    assert(std::is_heap(i105, i105+6, std::greater<int>()) == (std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+6));
+    assert(std::is_heap(i106, i106+6, std::greater<int>()) == (std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+6));
+    assert(std::is_heap(i107, i107+6, std::greater<int>()) == (std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+6));
+    assert(std::is_heap(i108, i108+6, std::greater<int>()) == (std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+6));
+    assert(std::is_heap(i109, i109+6, std::greater<int>()) == (std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+6));
+    assert(std::is_heap(i110, i110+6, std::greater<int>()) == (std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+6));
+    assert(std::is_heap(i111, i111+6, std::greater<int>()) == (std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+6));
+    assert(std::is_heap(i112, i112+6, std::greater<int>()) == (std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+6));
+    assert(std::is_heap(i113, i113+6, std::greater<int>()) == (std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+6));
+    assert(std::is_heap(i114, i114+6, std::greater<int>()) == (std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+6));
+    assert(std::is_heap(i115, i115+6, std::greater<int>()) == (std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+6));
+    assert(std::is_heap(i116, i116+6, std::greater<int>()) == (std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+6));
+    assert(std::is_heap(i117, i117+6, std::greater<int>()) == (std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+6));
+    assert(std::is_heap(i118, i118+6, std::greater<int>()) == (std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+6));
+    assert(std::is_heap(i119, i119+6, std::greater<int>()) == (std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+6));
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i120, i120+7, std::greater<int>()) == (std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7));
+    assert(std::is_heap(i121, i121+7, std::greater<int>()) == (std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7));
+    assert(std::is_heap(i122, i122+7, std::greater<int>()) == (std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7));
+    assert(std::is_heap(i123, i123+7, std::greater<int>()) == (std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7));
+    assert(std::is_heap(i124, i124+7, std::greater<int>()) == (std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7));
+    assert(std::is_heap(i125, i125+7, std::greater<int>()) == (std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7));
+    assert(std::is_heap(i126, i126+7, std::greater<int>()) == (std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7));
+    assert(std::is_heap(i127, i127+7, std::greater<int>()) == (std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7));
+    assert(std::is_heap(i128, i128+7, std::greater<int>()) == (std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7));
+    assert(std::is_heap(i129, i129+7, std::greater<int>()) == (std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7));
+    assert(std::is_heap(i130, i130+7, std::greater<int>()) == (std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7));
+    assert(std::is_heap(i131, i131+7, std::greater<int>()) == (std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7));
+    assert(std::is_heap(i132, i132+7, std::greater<int>()) == (std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7));
+    assert(std::is_heap(i133, i133+7, std::greater<int>()) == (std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7));
+    assert(std::is_heap(i134, i134+7, std::greater<int>()) == (std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7));
+    assert(std::is_heap(i135, i135+7, std::greater<int>()) == (std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7));
+    assert(std::is_heap(i136, i136+7, std::greater<int>()) == (std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+7));
+    assert(std::is_heap(i137, i137+7, std::greater<int>()) == (std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+7));
+    assert(std::is_heap(i138, i138+7, std::greater<int>()) == (std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+7));
+    assert(std::is_heap(i139, i139+7, std::greater<int>()) == (std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7));
+    assert(std::is_heap(i140, i140+7, std::greater<int>()) == (std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+7));
+    assert(std::is_heap(i141, i141+7, std::greater<int>()) == (std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+7));
+    assert(std::is_heap(i142, i142+7, std::greater<int>()) == (std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+7));
+    assert(std::is_heap(i143, i143+7, std::greater<int>()) == (std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7));
+    assert(std::is_heap(i144, i144+7, std::greater<int>()) == (std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+7));
+    assert(std::is_heap(i145, i145+7, std::greater<int>()) == (std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+7));
+    assert(std::is_heap(i146, i146+7, std::greater<int>()) == (std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+7));
+    assert(std::is_heap(i147, i147+7, std::greater<int>()) == (std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7));
+    assert(std::is_heap(i148, i148+7, std::greater<int>()) == (std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+7));
+    assert(std::is_heap(i149, i149+7, std::greater<int>()) == (std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+7));
+    assert(std::is_heap(i150, i150+7, std::greater<int>()) == (std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+7));
+    assert(std::is_heap(i151, i151+7, std::greater<int>()) == (std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7));
+    assert(std::is_heap(i152, i152+7, std::greater<int>()) == (std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+7));
+    assert(std::is_heap(i153, i153+7, std::greater<int>()) == (std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+7));
+    assert(std::is_heap(i154, i154+7, std::greater<int>()) == (std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+7));
+    assert(std::is_heap(i155, i155+7, std::greater<int>()) == (std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+7));
+    assert(std::is_heap(i156, i156+7, std::greater<int>()) == (std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+7));
+    assert(std::is_heap(i157, i157+7, std::greater<int>()) == (std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+7));
+    assert(std::is_heap(i158, i158+7, std::greater<int>()) == (std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+7));
+    assert(std::is_heap(i159, i159+7, std::greater<int>()) == (std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+7));
+    assert(std::is_heap(i160, i160+7, std::greater<int>()) == (std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+7));
+    assert(std::is_heap(i161, i161+7, std::greater<int>()) == (std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+7));
+    assert(std::is_heap(i162, i162+7, std::greater<int>()) == (std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+7));
+    assert(std::is_heap(i163, i163+7, std::greater<int>()) == (std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+7));
+    assert(std::is_heap(i164, i164+7, std::greater<int>()) == (std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7));
+    assert(std::is_heap(i165, i165+7, std::greater<int>()) == (std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7));
+    assert(std::is_heap(i166, i166+7, std::greater<int>()) == (std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7));
+    assert(std::is_heap(i167, i167+7, std::greater<int>()) == (std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7));
+    assert(std::is_heap(i168, i168+7, std::greater<int>()) == (std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+7));
+    assert(std::is_heap(i169, i169+7, std::greater<int>()) == (std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+7));
+    assert(std::is_heap(i170, i170+7, std::greater<int>()) == (std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+7));
+    assert(std::is_heap(i171, i171+7, std::greater<int>()) == (std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+7));
+    assert(std::is_heap(i172, i172+7, std::greater<int>()) == (std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+7));
+    assert(std::is_heap(i173, i173+7, std::greater<int>()) == (std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+7));
+    assert(std::is_heap(i174, i174+7, std::greater<int>()) == (std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+7));
+    assert(std::is_heap(i175, i175+7, std::greater<int>()) == (std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+7));
+    assert(std::is_heap(i176, i176+7, std::greater<int>()) == (std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+7));
+    assert(std::is_heap(i177, i177+7, std::greater<int>()) == (std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+7));
+    assert(std::is_heap(i178, i178+7, std::greater<int>()) == (std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+7));
+    assert(std::is_heap(i179, i179+7, std::greater<int>()) == (std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+7));
+    assert(std::is_heap(i180, i180+7, std::greater<int>()) == (std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+7));
+    assert(std::is_heap(i181, i181+7, std::greater<int>()) == (std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+7));
+    assert(std::is_heap(i182, i182+7, std::greater<int>()) == (std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+7));
+    assert(std::is_heap(i183, i183+7, std::greater<int>()) == (std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7));
+    assert(std::is_heap(i184, i184+7, std::greater<int>()) == (std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+7));
+    assert(std::is_heap(i185, i185+7, std::greater<int>()) == (std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+7));
+    assert(std::is_heap(i186, i186+7, std::greater<int>()) == (std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+7));
+    assert(std::is_heap(i187, i187+7, std::greater<int>()) == (std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+7));
+    assert(std::is_heap(i188, i188+7, std::greater<int>()) == (std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+7));
+    assert(std::is_heap(i189, i189+7, std::greater<int>()) == (std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+7));
+    assert(std::is_heap(i190, i190+7, std::greater<int>()) == (std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+7));
+    assert(std::is_heap(i191, i191+7, std::greater<int>()) == (std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+7));
+    assert(std::is_heap(i192, i192+7, std::greater<int>()) == (std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+7));
+    assert(std::is_heap(i193, i193+7, std::greater<int>()) == (std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+7));
+    assert(std::is_heap(i194, i194+7, std::greater<int>()) == (std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+7));
+    assert(std::is_heap(i195, i195+7, std::greater<int>()) == (std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+7));
+    assert(std::is_heap(i196, i196+7, std::greater<int>()) == (std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+7));
+    assert(std::is_heap(i197, i197+7, std::greater<int>()) == (std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+7));
+    assert(std::is_heap(i198, i198+7, std::greater<int>()) == (std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+7));
+    assert(std::is_heap(i199, i199+7, std::greater<int>()) == (std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+7));
+    assert(std::is_heap(i200, i200+7, std::greater<int>()) == (std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+7));
+    assert(std::is_heap(i201, i201+7, std::greater<int>()) == (std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+7));
+    assert(std::is_heap(i202, i202+7, std::greater<int>()) == (std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+7));
+    assert(std::is_heap(i203, i203+7, std::greater<int>()) == (std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+7));
+    assert(std::is_heap(i204, i204+7, std::greater<int>()) == (std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+7));
+    assert(std::is_heap(i205, i205+7, std::greater<int>()) == (std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+7));
+    assert(std::is_heap(i206, i206+7, std::greater<int>()) == (std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+7));
+    assert(std::is_heap(i207, i207+7, std::greater<int>()) == (std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+7));
+    assert(std::is_heap(i208, i208+7, std::greater<int>()) == (std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+7));
+    assert(std::is_heap(i209, i209+7, std::greater<int>()) == (std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+7));
+    assert(std::is_heap(i210, i210+7, std::greater<int>()) == (std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+7));
+    assert(std::is_heap(i211, i211+7, std::greater<int>()) == (std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+7));
+    assert(std::is_heap(i212, i212+7, std::greater<int>()) == (std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+7));
+    assert(std::is_heap(i213, i213+7, std::greater<int>()) == (std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+7));
+    assert(std::is_heap(i214, i214+7, std::greater<int>()) == (std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+7));
+    assert(std::is_heap(i215, i215+7, std::greater<int>()) == (std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+7));
+    assert(std::is_heap(i216, i216+7, std::greater<int>()) == (std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+7));
+    assert(std::is_heap(i217, i217+7, std::greater<int>()) == (std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+7));
+    assert(std::is_heap(i218, i218+7, std::greater<int>()) == (std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+7));
+    assert(std::is_heap(i219, i219+7, std::greater<int>()) == (std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+7));
+    assert(std::is_heap(i220, i220+7, std::greater<int>()) == (std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+7));
+    assert(std::is_heap(i221, i221+7, std::greater<int>()) == (std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+7));
+    assert(std::is_heap(i222, i222+7, std::greater<int>()) == (std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+7));
+    assert(std::is_heap(i223, i223+7, std::greater<int>()) == (std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+7));
+    assert(std::is_heap(i224, i224+7, std::greater<int>()) == (std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+7));
+    assert(std::is_heap(i225, i225+7, std::greater<int>()) == (std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+7));
+    assert(std::is_heap(i226, i226+7, std::greater<int>()) == (std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+7));
+    assert(std::is_heap(i227, i227+7, std::greater<int>()) == (std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+7));
+    assert(std::is_heap(i228, i228+7, std::greater<int>()) == (std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+7));
+    assert(std::is_heap(i229, i229+7, std::greater<int>()) == (std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+7));
+    assert(std::is_heap(i230, i230+7, std::greater<int>()) == (std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+7));
+    assert(std::is_heap(i231, i231+7, std::greater<int>()) == (std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+7));
+    assert(std::is_heap(i232, i232+7, std::greater<int>()) == (std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+7));
+    assert(std::is_heap(i233, i233+7, std::greater<int>()) == (std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+7));
+    assert(std::is_heap(i234, i234+7, std::greater<int>()) == (std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+7));
+    assert(std::is_heap(i235, i235+7, std::greater<int>()) == (std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+7));
+    assert(std::is_heap(i236, i236+7, std::greater<int>()) == (std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+7));
+    assert(std::is_heap(i237, i237+7, std::greater<int>()) == (std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+7));
+    assert(std::is_heap(i238, i238+7, std::greater<int>()) == (std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+7));
+    assert(std::is_heap(i239, i239+7, std::greater<int>()) == (std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+7));
+    assert(std::is_heap(i240, i240+7, std::greater<int>()) == (std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+7));
+    assert(std::is_heap(i241, i241+7, std::greater<int>()) == (std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+7));
+    assert(std::is_heap(i242, i242+7, std::greater<int>()) == (std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+7));
+    assert(std::is_heap(i243, i243+7, std::greater<int>()) == (std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+7));
+    assert(std::is_heap(i244, i244+7, std::greater<int>()) == (std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+7));
+    assert(std::is_heap(i245, i245+7, std::greater<int>()) == (std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+7));
+    assert(std::is_heap(i246, i246+7, std::greater<int>()) == (std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+7));
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
new file mode 100644
index 0000000..f42f7f6
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   Iter
+//   is_heap_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap_until(i1, i1) == i1);
+    assert(std::is_heap_until(i1, i1+1) == i1+1);
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap_until(i1, i1+2) == i1+2);
+    assert(std::is_heap_until(i2, i2+2) == i2+1);
+    assert(std::is_heap_until(i3, i3+2) == i3+2);
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap_until(i4, i4+3) == i4+3);
+    assert(std::is_heap_until(i5, i5+3) == i5+2);
+    assert(std::is_heap_until(i6, i6+3) == i6+1);
+    assert(std::is_heap_until(i7, i7+3) == i7+1);
+    assert(std::is_heap_until(i8, i8+3) == i8+3);
+    assert(std::is_heap_until(i9, i9+3) == i9+3);
+    assert(std::is_heap_until(i10, i10+3) == i10+3);
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap_until(i11, i11+4) == i11+4);
+    assert(std::is_heap_until(i12, i12+4) == i12+3);
+    assert(std::is_heap_until(i13, i13+4) == i13+2);
+    assert(std::is_heap_until(i14, i14+4) == i14+2);
+    assert(std::is_heap_until(i15, i15+4) == i15+1);
+    assert(std::is_heap_until(i16, i16+4) == i16+1);
+    assert(std::is_heap_until(i17, i17+4) == i17+1);
+    assert(std::is_heap_until(i18, i18+4) == i18+1);
+    assert(std::is_heap_until(i19, i19+4) == i19+4);
+    assert(std::is_heap_until(i20, i20+4) == i20+3);
+    assert(std::is_heap_until(i21, i21+4) == i21+4);
+    assert(std::is_heap_until(i22, i22+4) == i22+3);
+    assert(std::is_heap_until(i23, i23+4) == i23+4);
+    assert(std::is_heap_until(i24, i24+4) == i24+4);
+    assert(std::is_heap_until(i25, i25+4) == i25+4);
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i26, i26+5) == i26+5);
+    assert(std::is_heap_until(i27, i27+5) == i27+4);
+    assert(std::is_heap_until(i28, i28+5) == i28+3);
+    assert(std::is_heap_until(i29, i29+5) == i29+3);
+    assert(std::is_heap_until(i30, i30+5) == i30+2);
+    assert(std::is_heap_until(i31, i31+5) == i31+2);
+    assert(std::is_heap_until(i32, i32+5) == i32+2);
+    assert(std::is_heap_until(i33, i33+5) == i33+2);
+    assert(std::is_heap_until(i34, i34+5) == i34+1);
+    assert(std::is_heap_until(i35, i35+5) == i35+1);
+    assert(std::is_heap_until(i36, i36+5) == i36+1);
+    assert(std::is_heap_until(i37, i37+5) == i37+1);
+    assert(std::is_heap_until(i38, i38+5) == i38+1);
+    assert(std::is_heap_until(i39, i39+5) == i39+1);
+    assert(std::is_heap_until(i40, i40+5) == i40+1);
+    assert(std::is_heap_until(i41, i41+5) == i41+1);
+    assert(std::is_heap_until(i42, i42+5) == i42+5);
+    assert(std::is_heap_until(i43, i43+5) == i43+4);
+    assert(std::is_heap_until(i44, i44+5) == i44+3);
+    assert(std::is_heap_until(i45, i45+5) == i45+3);
+    assert(std::is_heap_until(i46, i46+5) == i46+5);
+    assert(std::is_heap_until(i47, i47+5) == i47+4);
+    assert(std::is_heap_until(i48, i48+5) == i48+3);
+    assert(std::is_heap_until(i49, i49+5) == i49+3);
+    assert(std::is_heap_until(i50, i50+5) == i50+5);
+    assert(std::is_heap_until(i51, i51+5) == i51+5);
+    assert(std::is_heap_until(i52, i52+5) == i52+5);
+    assert(std::is_heap_until(i53, i53+5) == i53+5);
+    assert(std::is_heap_until(i54, i54+5) == i54+5);
+    assert(std::is_heap_until(i55, i55+5) == i55+5);
+    assert(std::is_heap_until(i56, i56+5) == i56+5);
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i57, i57+6) == i57+6);
+    assert(std::is_heap_until(i58, i58+6) == i58+5);
+    assert(std::is_heap_until(i59, i59+6) == i59+4);
+    assert(std::is_heap_until(i60, i60+6) == i60+4);
+    assert(std::is_heap_until(i61, i61+6) == i61+3);
+    assert(std::is_heap_until(i62, i62+6) == i62+3);
+    assert(std::is_heap_until(i63, i63+6) == i63+3);
+    assert(std::is_heap_until(i64, i64+6) == i64+3);
+    assert(std::is_heap_until(i65, i65+6) == i65+2);
+    assert(std::is_heap_until(i66, i66+6) == i66+2);
+    assert(std::is_heap_until(i67, i67+6) == i67+2);
+    assert(std::is_heap_until(i68, i68+6) == i68+2);
+    assert(std::is_heap_until(i69, i69+6) == i69+2);
+    assert(std::is_heap_until(i70, i70+6) == i70+2);
+    assert(std::is_heap_until(i71, i71+6) == i71+2);
+    assert(std::is_heap_until(i72, i72+6) == i72+2);
+    assert(std::is_heap_until(i73, i73+6) == i73+1);
+    assert(std::is_heap_until(i74, i74+6) == i74+1);
+    assert(std::is_heap_until(i75, i75+6) == i75+1);
+    assert(std::is_heap_until(i76, i76+6) == i76+1);
+    assert(std::is_heap_until(i77, i77+6) == i77+1);
+    assert(std::is_heap_until(i78, i78+6) == i78+1);
+    assert(std::is_heap_until(i79, i79+6) == i79+1);
+    assert(std::is_heap_until(i80, i80+6) == i80+1);
+    assert(std::is_heap_until(i81, i81+6) == i81+1);
+    assert(std::is_heap_until(i82, i82+6) == i82+1);
+    assert(std::is_heap_until(i83, i83+6) == i83+1);
+    assert(std::is_heap_until(i84, i84+6) == i84+1);
+    assert(std::is_heap_until(i85, i85+6) == i85+1);
+    assert(std::is_heap_until(i86, i86+6) == i86+1);
+    assert(std::is_heap_until(i87, i87+6) == i87+1);
+    assert(std::is_heap_until(i88, i88+6) == i88+1);
+    assert(std::is_heap_until(i89, i89+6) == i89+6);
+    assert(std::is_heap_until(i90, i90+6) == i90+5);
+    assert(std::is_heap_until(i91, i91+6) == i91+4);
+    assert(std::is_heap_until(i92, i92+6) == i92+4);
+    assert(std::is_heap_until(i93, i93+6) == i93+3);
+    assert(std::is_heap_until(i94, i94+6) == i94+3);
+    assert(std::is_heap_until(i95, i95+6) == i95+3);
+    assert(std::is_heap_until(i96, i96+6) == i96+3);
+    assert(std::is_heap_until(i97, i97+6) == i97+6);
+    assert(std::is_heap_until(i98, i98+6) == i98+6);
+    assert(std::is_heap_until(i99, i99+6) == i99+4);
+    assert(std::is_heap_until(i100, i100+6) == i100+4);
+    assert(std::is_heap_until(i101, i101+6) == i101+3);
+    assert(std::is_heap_until(i102, i102+6) == i102+3);
+    assert(std::is_heap_until(i103, i103+6) == i103+3);
+    assert(std::is_heap_until(i104, i104+6) == i104+3);
+    assert(std::is_heap_until(i105, i105+6) == i105+6);
+    assert(std::is_heap_until(i106, i106+6) == i106+5);
+    assert(std::is_heap_until(i107, i107+6) == i107+6);
+    assert(std::is_heap_until(i108, i108+6) == i108+5);
+    assert(std::is_heap_until(i109, i109+6) == i109+6);
+    assert(std::is_heap_until(i110, i110+6) == i110+5);
+    assert(std::is_heap_until(i111, i111+6) == i111+6);
+    assert(std::is_heap_until(i112, i112+6) == i112+5);
+    assert(std::is_heap_until(i113, i113+6) == i113+6);
+    assert(std::is_heap_until(i114, i114+6) == i114+6);
+    assert(std::is_heap_until(i115, i115+6) == i115+6);
+    assert(std::is_heap_until(i116, i116+6) == i116+6);
+    assert(std::is_heap_until(i117, i117+6) == i117+6);
+    assert(std::is_heap_until(i118, i118+6) == i118+6);
+    assert(std::is_heap_until(i119, i119+6) == i119+6);
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i120, i120+7) == i120+7);
+    assert(std::is_heap_until(i121, i121+7) == i121+6);
+    assert(std::is_heap_until(i122, i122+7) == i122+5);
+    assert(std::is_heap_until(i123, i123+7) == i123+5);
+    assert(std::is_heap_until(i124, i124+7) == i124+4);
+    assert(std::is_heap_until(i125, i125+7) == i125+4);
+    assert(std::is_heap_until(i126, i126+7) == i126+4);
+    assert(std::is_heap_until(i127, i127+7) == i127+4);
+    assert(std::is_heap_until(i128, i128+7) == i128+3);
+    assert(std::is_heap_until(i129, i129+7) == i129+3);
+    assert(std::is_heap_until(i130, i130+7) == i130+3);
+    assert(std::is_heap_until(i131, i131+7) == i131+3);
+    assert(std::is_heap_until(i132, i132+7) == i132+3);
+    assert(std::is_heap_until(i133, i133+7) == i133+3);
+    assert(std::is_heap_until(i134, i134+7) == i134+3);
+    assert(std::is_heap_until(i135, i135+7) == i135+3);
+    assert(std::is_heap_until(i136, i136+7) == i136+2);
+    assert(std::is_heap_until(i137, i137+7) == i137+2);
+    assert(std::is_heap_until(i138, i138+7) == i138+2);
+    assert(std::is_heap_until(i139, i139+7) == i139+2);
+    assert(std::is_heap_until(i140, i140+7) == i140+2);
+    assert(std::is_heap_until(i141, i141+7) == i141+2);
+    assert(std::is_heap_until(i142, i142+7) == i142+2);
+    assert(std::is_heap_until(i143, i143+7) == i143+2);
+    assert(std::is_heap_until(i144, i144+7) == i144+2);
+    assert(std::is_heap_until(i145, i145+7) == i145+2);
+    assert(std::is_heap_until(i146, i146+7) == i146+2);
+    assert(std::is_heap_until(i147, i147+7) == i147+2);
+    assert(std::is_heap_until(i148, i148+7) == i148+2);
+    assert(std::is_heap_until(i149, i149+7) == i149+2);
+    assert(std::is_heap_until(i150, i150+7) == i150+2);
+    assert(std::is_heap_until(i151, i151+7) == i151+2);
+    assert(std::is_heap_until(i152, i152+7) == i152+1);
+    assert(std::is_heap_until(i153, i153+7) == i153+1);
+    assert(std::is_heap_until(i154, i154+7) == i154+1);
+    assert(std::is_heap_until(i155, i155+7) == i155+1);
+    assert(std::is_heap_until(i156, i156+7) == i156+1);
+    assert(std::is_heap_until(i157, i157+7) == i157+1);
+    assert(std::is_heap_until(i158, i158+7) == i158+1);
+    assert(std::is_heap_until(i159, i159+7) == i159+1);
+    assert(std::is_heap_until(i160, i160+7) == i160+1);
+    assert(std::is_heap_until(i161, i161+7) == i161+1);
+    assert(std::is_heap_until(i162, i162+7) == i162+1);
+    assert(std::is_heap_until(i163, i163+7) == i163+1);
+    assert(std::is_heap_until(i164, i164+7) == i164+1);
+    assert(std::is_heap_until(i165, i165+7) == i165+1);
+    assert(std::is_heap_until(i166, i166+7) == i166+1);
+    assert(std::is_heap_until(i167, i167+7) == i167+1);
+    assert(std::is_heap_until(i168, i168+7) == i168+1);
+    assert(std::is_heap_until(i169, i169+7) == i169+1);
+    assert(std::is_heap_until(i170, i170+7) == i170+1);
+    assert(std::is_heap_until(i171, i171+7) == i171+1);
+    assert(std::is_heap_until(i172, i172+7) == i172+1);
+    assert(std::is_heap_until(i173, i173+7) == i173+1);
+    assert(std::is_heap_until(i174, i174+7) == i174+1);
+    assert(std::is_heap_until(i175, i175+7) == i175+1);
+    assert(std::is_heap_until(i176, i176+7) == i176+1);
+    assert(std::is_heap_until(i177, i177+7) == i177+1);
+    assert(std::is_heap_until(i178, i178+7) == i178+1);
+    assert(std::is_heap_until(i179, i179+7) == i179+1);
+    assert(std::is_heap_until(i180, i180+7) == i180+1);
+    assert(std::is_heap_until(i181, i181+7) == i181+1);
+    assert(std::is_heap_until(i182, i182+7) == i182+1);
+    assert(std::is_heap_until(i183, i183+7) == i183+1);
+    assert(std::is_heap_until(i184, i184+7) == i184+7);
+    assert(std::is_heap_until(i185, i185+7) == i185+6);
+    assert(std::is_heap_until(i186, i186+7) == i186+5);
+    assert(std::is_heap_until(i187, i187+7) == i187+5);
+    assert(std::is_heap_until(i188, i188+7) == i188+4);
+    assert(std::is_heap_until(i189, i189+7) == i189+4);
+    assert(std::is_heap_until(i190, i190+7) == i190+4);
+    assert(std::is_heap_until(i191, i191+7) == i191+4);
+    assert(std::is_heap_until(i192, i192+7) == i192+3);
+    assert(std::is_heap_until(i193, i193+7) == i193+3);
+    assert(std::is_heap_until(i194, i194+7) == i194+3);
+    assert(std::is_heap_until(i195, i195+7) == i195+3);
+    assert(std::is_heap_until(i196, i196+7) == i196+3);
+    assert(std::is_heap_until(i197, i197+7) == i197+3);
+    assert(std::is_heap_until(i198, i198+7) == i198+3);
+    assert(std::is_heap_until(i199, i199+7) == i199+3);
+    assert(std::is_heap_until(i200, i200+7) == i200+7);
+    assert(std::is_heap_until(i201, i201+7) == i201+7);
+    assert(std::is_heap_until(i202, i202+7) == i202+7);
+    assert(std::is_heap_until(i203, i203+7) == i203+7);
+    assert(std::is_heap_until(i204, i204+7) == i204+4);
+    assert(std::is_heap_until(i205, i205+7) == i205+4);
+    assert(std::is_heap_until(i206, i206+7) == i206+4);
+    assert(std::is_heap_until(i207, i207+7) == i207+4);
+    assert(std::is_heap_until(i208, i208+7) == i208+3);
+    assert(std::is_heap_until(i209, i209+7) == i209+3);
+    assert(std::is_heap_until(i210, i210+7) == i210+3);
+    assert(std::is_heap_until(i211, i211+7) == i211+3);
+    assert(std::is_heap_until(i212, i212+7) == i212+3);
+    assert(std::is_heap_until(i213, i213+7) == i213+3);
+    assert(std::is_heap_until(i214, i214+7) == i214+3);
+    assert(std::is_heap_until(i215, i215+7) == i215+3);
+    assert(std::is_heap_until(i216, i216+7) == i216+7);
+    assert(std::is_heap_until(i217, i217+7) == i217+6);
+    assert(std::is_heap_until(i218, i218+7) == i218+5);
+    assert(std::is_heap_until(i219, i219+7) == i219+5);
+    assert(std::is_heap_until(i220, i220+7) == i220+7);
+    assert(std::is_heap_until(i221, i221+7) == i221+6);
+    assert(std::is_heap_until(i222, i222+7) == i222+5);
+    assert(std::is_heap_until(i223, i223+7) == i223+5);
+    assert(std::is_heap_until(i224, i224+7) == i224+7);
+    assert(std::is_heap_until(i225, i225+7) == i225+6);
+    assert(std::is_heap_until(i226, i226+7) == i226+5);
+    assert(std::is_heap_until(i227, i227+7) == i227+5);
+    assert(std::is_heap_until(i228, i228+7) == i228+7);
+    assert(std::is_heap_until(i229, i229+7) == i229+6);
+    assert(std::is_heap_until(i230, i230+7) == i230+5);
+    assert(std::is_heap_until(i231, i231+7) == i231+5);
+    assert(std::is_heap_until(i232, i232+7) == i232+7);
+    assert(std::is_heap_until(i233, i233+7) == i233+7);
+    assert(std::is_heap_until(i234, i234+7) == i234+7);
+    assert(std::is_heap_until(i235, i235+7) == i235+7);
+    assert(std::is_heap_until(i236, i236+7) == i236+7);
+    assert(std::is_heap_until(i237, i237+7) == i237+7);
+    assert(std::is_heap_until(i238, i238+7) == i238+7);
+    assert(std::is_heap_until(i239, i239+7) == i239+7);
+    assert(std::is_heap_until(i240, i240+7) == i240+7);
+    assert(std::is_heap_until(i241, i241+7) == i241+7);
+    assert(std::is_heap_until(i242, i242+7) == i242+7);
+    assert(std::is_heap_until(i243, i243+7) == i243+7);
+    assert(std::is_heap_until(i244, i244+7) == i244+7);
+    assert(std::is_heap_until(i245, i245+7) == i245+7);
+    assert(std::is_heap_until(i246, i246+7) == i246+7);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
new file mode 100644
index 0000000..87f845f
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   Iter
+//   is_heap_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap_until(i1, i1, std::greater<int>()) == i1);
+    assert(std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1);
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2);
+    assert(std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2);
+    assert(std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+1);
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3);
+    assert(std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3);
+    assert(std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3);
+    assert(std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3);
+    assert(std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+1);
+    assert(std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+1);
+    assert(std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+2);
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4);
+    assert(std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4);
+    assert(std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4);
+    assert(std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4);
+    assert(std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+3);
+    assert(std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4);
+    assert(std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+3);
+    assert(std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4);
+    assert(std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+1);
+    assert(std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+1);
+    assert(std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+1);
+    assert(std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+1);
+    assert(std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+2);
+    assert(std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+2);
+    assert(std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+3);
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5);
+    assert(std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5);
+    assert(std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5);
+    assert(std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5);
+    assert(std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5);
+    assert(std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5);
+    assert(std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5);
+    assert(std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5);
+    assert(std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+3);
+    assert(std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+3);
+    assert(std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+4);
+    assert(std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5);
+    assert(std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+3);
+    assert(std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+3);
+    assert(std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+4);
+    assert(std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5);
+    assert(std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+1);
+    assert(std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+1);
+    assert(std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+1);
+    assert(std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+1);
+    assert(std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+1);
+    assert(std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+1);
+    assert(std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+1);
+    assert(std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+1);
+    assert(std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+2);
+    assert(std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+2);
+    assert(std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+2);
+    assert(std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+2);
+    assert(std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+3);
+    assert(std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+3);
+    assert(std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+4);
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6);
+    assert(std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6);
+    assert(std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6);
+    assert(std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6);
+    assert(std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6);
+    assert(std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6);
+    assert(std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6);
+    assert(std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6);
+    assert(std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+5);
+    assert(std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6);
+    assert(std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+5);
+    assert(std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6);
+    assert(std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+5);
+    assert(std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6);
+    assert(std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+5);
+    assert(std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6);
+    assert(std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+3);
+    assert(std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+3);
+    assert(std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+3);
+    assert(std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+3);
+    assert(std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+4);
+    assert(std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+4);
+    assert(std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6);
+    assert(std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6);
+    assert(std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+3);
+    assert(std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+3);
+    assert(std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+3);
+    assert(std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+3);
+    assert(std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+4);
+    assert(std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+4);
+    assert(std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+5);
+    assert(std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6);
+    assert(std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+1);
+    assert(std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+1);
+    assert(std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+1);
+    assert(std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+1);
+    assert(std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+1);
+    assert(std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+1);
+    assert(std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+1);
+    assert(std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+1);
+    assert(std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+1);
+    assert(std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+1);
+    assert(std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+1);
+    assert(std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+1);
+    assert(std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+1);
+    assert(std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+1);
+    assert(std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+1);
+    assert(std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+1);
+    assert(std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+2);
+    assert(std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+2);
+    assert(std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+2);
+    assert(std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+2);
+    assert(std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+2);
+    assert(std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+2);
+    assert(std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+2);
+    assert(std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+2);
+    assert(std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+3);
+    assert(std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+3);
+    assert(std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+3);
+    assert(std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+3);
+    assert(std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+4);
+    assert(std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+4);
+    assert(std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+5);
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7);
+    assert(std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7);
+    assert(std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7);
+    assert(std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7);
+    assert(std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7);
+    assert(std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7);
+    assert(std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7);
+    assert(std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7);
+    assert(std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7);
+    assert(std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7);
+    assert(std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7);
+    assert(std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7);
+    assert(std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7);
+    assert(std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7);
+    assert(std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7);
+    assert(std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7);
+    assert(std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+5);
+    assert(std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+5);
+    assert(std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+6);
+    assert(std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7);
+    assert(std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+5);
+    assert(std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+5);
+    assert(std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+6);
+    assert(std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7);
+    assert(std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+5);
+    assert(std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+5);
+    assert(std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+6);
+    assert(std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7);
+    assert(std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+5);
+    assert(std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+5);
+    assert(std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+6);
+    assert(std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7);
+    assert(std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+3);
+    assert(std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+3);
+    assert(std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+3);
+    assert(std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+3);
+    assert(std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+3);
+    assert(std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+3);
+    assert(std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+3);
+    assert(std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+3);
+    assert(std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+4);
+    assert(std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+4);
+    assert(std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+4);
+    assert(std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+4);
+    assert(std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7);
+    assert(std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7);
+    assert(std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7);
+    assert(std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7);
+    assert(std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+3);
+    assert(std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+3);
+    assert(std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+3);
+    assert(std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+3);
+    assert(std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+3);
+    assert(std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+3);
+    assert(std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+3);
+    assert(std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+3);
+    assert(std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+4);
+    assert(std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+4);
+    assert(std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+4);
+    assert(std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+4);
+    assert(std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+5);
+    assert(std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+5);
+    assert(std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+6);
+    assert(std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7);
+    assert(std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+1);
+    assert(std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+1);
+    assert(std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+1);
+    assert(std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+1);
+    assert(std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+1);
+    assert(std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+1);
+    assert(std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+1);
+    assert(std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+1);
+    assert(std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+1);
+    assert(std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+1);
+    assert(std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+1);
+    assert(std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+1);
+    assert(std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+1);
+    assert(std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+1);
+    assert(std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+1);
+    assert(std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+1);
+    assert(std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+1);
+    assert(std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+1);
+    assert(std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+1);
+    assert(std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+1);
+    assert(std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+1);
+    assert(std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+1);
+    assert(std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+1);
+    assert(std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+1);
+    assert(std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+1);
+    assert(std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+1);
+    assert(std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+1);
+    assert(std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+1);
+    assert(std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+1);
+    assert(std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+1);
+    assert(std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+1);
+    assert(std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+1);
+    assert(std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+2);
+    assert(std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+2);
+    assert(std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+2);
+    assert(std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+2);
+    assert(std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+2);
+    assert(std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+2);
+    assert(std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+2);
+    assert(std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+2);
+    assert(std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+2);
+    assert(std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+2);
+    assert(std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+2);
+    assert(std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+2);
+    assert(std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+2);
+    assert(std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+2);
+    assert(std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+2);
+    assert(std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+2);
+    assert(std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+3);
+    assert(std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+3);
+    assert(std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+3);
+    assert(std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+3);
+    assert(std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+3);
+    assert(std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+3);
+    assert(std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+3);
+    assert(std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+3);
+    assert(std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+4);
+    assert(std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+4);
+    assert(std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+4);
+    assert(std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+4);
+    assert(std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+5);
+    assert(std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+5);
+    assert(std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+6);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
new file mode 100644
index 0000000..26f0539
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type> 
+//   void
+//   make_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    assert(std::is_heap(ia, ia+N));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
new file mode 100644
index 0000000..c33945b
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare> 
+//   void
+//   make_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    assert(std::is_heap(ia, ia+N, std::greater<int>()));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+
+#ifdef _LIBCPP_MOVE
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    assert(std::is_heap(ia, ia+N, indirect_less()));
+    delete [] ia;
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
new file mode 100644
index 0000000..3695f96
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type> 
+//   void
+//   pop_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i);
+        assert(std::is_heap(ia, ia+i-1));
+    }
+    std::pop_heap(ia, ia);
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
new file mode 100644
index 0000000..bb85643
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare> 
+//   void
+//   pop_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i, std::greater<int>());
+        assert(std::is_heap(ia, ia+i-1, std::greater<int>()));
+    }
+    std::pop_heap(ia, ia, std::greater<int>());
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+
+#ifdef _LIBCPP_MOVE
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i, indirect_less());
+        assert(std::is_heap(ia, ia+i-1, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
new file mode 100644
index 0000000..5cf53f4
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i);
+        assert(std::is_heap(ia, ia+i));
+    }
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
new file mode 100644
index 0000000..ab41df2
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i, std::greater<int>());
+        assert(std::is_heap(ia, ia+i, std::greater<int>()));
+    }
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+
+#ifdef _LIBCPP_MOVE
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i, indirect_less());
+        assert(std::is_heap(ia, ia+i, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
new file mode 100644
index 0000000..517a98c
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type> 
+//   void
+//   sort_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    std::sort_heap(ia, ia+N);
+    assert(std::is_sorted(ia, ia+N));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+}
diff --git a/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
new file mode 100644
index 0000000..d0ebbc8
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare> 
+//   void
+//   sort_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    std::sort_heap(ia, ia+N, std::greater<int>());
+    assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+
+#ifdef _LIBCPP_MOVE
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    std::sort_heap(ia, ia+N, indirect_less());
+    assert(std::is_sorted(ia, ia+N, indirect_less()));
+    delete [] ia;
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp b/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
new file mode 100644
index 0000000..7fa7389
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2> 
+//   requires HasLess<Iter1::value_type, Iter2::value_type> 
+//         && HasLess<Iter2::value_type, Iter1::value_type> 
+//   bool
+//   lexicographical_compare(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 2, 3};
+    assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+2));
+    assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa));
+    assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3));
+    assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa));
+    assert(std::lexicographical_compare(ia, ia+sa, ib+1, ib+3));
+    assert(!std::lexicographical_compare(ib+1, ib+3, ia, ia+sa));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp b/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
new file mode 100644
index 0000000..f5854c7
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, CopyConstructible Compare> 
+//   requires Predicate<Compare, Iter1::value_type, Iter2::value_type> 
+//         && Predicate<Compare, Iter2::value_type, Iter1::value_type> 
+//   bool
+//   lexicographical_compare(Iter1 first1, Iter1 last1,
+//                           Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 2, 3};
+    typedef std::greater<int> C;
+    C c;
+    assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+2, c));
+    assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa, c));
+    assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3, c));
+    assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa, c));
+    assert(!std::lexicographical_compare(ia, ia+sa, ib+1, ib+3, c));
+    assert(std::lexicographical_compare(ib+1, ib+3, ia, ia+sa, c));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
new file mode 100644
index 0000000..563aac4
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   inplace_merge(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(M <= N);
+    int* ia = new int[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M);
+    std::sort(ia+M, ia+N);
+    std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N));
+    if(N > 0)
+    {
+        assert(ia[0] == 0);
+        assert(ia[N-1] == N-1);
+        assert(std::is_sorted(ia, ia+N));
+    }
+    delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    test_one<Iter>(N, 0);
+    test_one<Iter>(N, N/4);
+    test_one<Iter>(N, N/2);
+    test_one<Iter>(N, 3*N/4);
+    test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_one<Iter>(0, 0);
+    test_one<Iter>(1, 0);
+    test_one<Iter>(1, 1);
+    test_one<Iter>(2, 0);
+    test_one<Iter>(2, 1);
+    test_one<Iter>(2, 2);
+    test_one<Iter>(3, 0);
+    test_one<Iter>(3, 1);
+    test_one<Iter>(3, 2);
+    test_one<Iter>(3, 3);
+    test<Iter>(4);
+    test<Iter>(100);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
new file mode 100644
index 0000000..29b43b7
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   void
+//   inplace_merge(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(M <= N);
+    int* ia = new int[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M, std::greater<int>());
+    std::sort(ia+M, ia+N, std::greater<int>());
+    std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::greater<int>());
+    if(N > 0)
+    {
+        assert(ia[0] == N-1);
+        assert(ia[N-1] == 0);
+        assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+    }
+    delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    test_one<Iter>(N, 0);
+    test_one<Iter>(N, N/4);
+    test_one<Iter>(N, N/2);
+    test_one<Iter>(N, 3*N/4);
+    test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_one<Iter>(0, 0);
+    test_one<Iter>(1, 0);
+    test_one<Iter>(1, 1);
+    test_one<Iter>(2, 0);
+    test_one<Iter>(2, 1);
+    test_one<Iter>(2, 2);
+    test_one<Iter>(3, 0);
+    test_one<Iter>(3, 1);
+    test_one<Iter>(3, 2);
+    test_one<Iter>(3, 3);
+    test<Iter>(4);
+    test<Iter>(100);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifdef _LIBCPP_MOVE
+    {
+    unsigned N = 100;
+    unsigned M = 50;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int>[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M, indirect_less());
+    std::sort(ia+M, ia+N, indirect_less());
+    std::inplace_merge(ia, ia+M, ia+N, indirect_less());
+    if(N > 0)
+    {
+        assert(*ia[0] == 0);
+        assert(*ia[N-1] == N-1);
+        assert(std::is_sorted(ia, ia+N, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp
new file mode 100644
index 0000000..1b5f5de
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && HasLess<InIter2::value_type, InIter1::value_type> 
+//   OutIter
+//   merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    {
+    unsigned N = 100000;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = 2*i;
+    for (unsigned i = 0; i < N; ++i)
+        ib[i] = 2*i+1;
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic));
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 0);
+    assert(ic[2*N-1] == 2*N-1);
+    assert(std::is_sorted(ic, ic+2*N));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+    {
+    unsigned N = 100;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < 2*N; ++i)
+        ic[i] = i;
+    std::random_shuffle(ic, ic+2*N);
+    std::copy(ic, ic+N, ia);
+    std::copy(ic+N, ic+2*N, ib);
+    std::sort(ia, ia+N);
+    std::sort(ib, ib+N);
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic));
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 0);
+    assert(ic[2*N-1] == 2*N-1);
+    assert(std::is_sorted(ic, ic+2*N));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
new file mode 100644
index 0000000..64e9148
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter, 
+//          Predicate<auto, InIter2::value_type, InIter1::value_type> Compare> 
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && CopyConstructible<Compare> 
+//   OutIter
+//   merge(InIter1 first1, InIter1 last1,
+//         InIter2 first2, InIter2 last2, OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    {
+    unsigned N = 100000;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = 2*i;
+    for (unsigned i = 0; i < N; ++i)
+        ib[i] = 2*i+1;
+    std::reverse(ia, ia+N);
+    std::reverse(ib, ib+N);
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 2*N-1);
+    assert(ic[2*N-1] == 0);
+    assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+    {
+    unsigned N = 100;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < 2*N; ++i)
+        ic[i] = i;
+    std::random_shuffle(ic, ic+2*N);
+    std::copy(ic, ic+N, ia);
+    std::copy(ic+N, ic+2*N, ib);
+    std::sort(ia, ia+N, std::greater<int>());
+    std::sort(ib, ib+N, std::greater<int>());
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 2*N-1);
+    assert(ic[2*N-1] == 0);
+    assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp
new file mode 100644
index 0000000..0f7caca
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   const T&
+//   max(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+    assert(&std::max(a, b) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, y);
+    test(y, x, y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, x);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
new file mode 100644
index 0000000..942b01f
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare> 
+//   requires !SameType<T, Compare> && CopyConstructible<Compare> 
+//   const T&
+//   max(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+    assert(&std::max(a, b, c) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), x);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), y);
+    test(y, x, std::greater<int>(), y);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
new file mode 100644
index 0000000..fec9b03
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   Iter
+//   max_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::max_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!(*i < *j));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
new file mode 100644
index 0000000..c23d20c
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max_element_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   Iter
+//   max_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::max_element(first, last, std::greater<int>());
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!std::greater<int>()(*i, *j));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
new file mode 100644
index 0000000..9303bd1
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class T> 
+//   T
+//   max(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+#error max(initializer_list<T> t) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
new file mode 100644
index 0000000..728a27b
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare> 
+//   T
+//   max(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <cassert>
+
+#error max(initializer_list<T> t, Compare comp) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp
new file mode 100644
index 0000000..634c109
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   const T&
+//   min(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+    assert(&std::min(a, b) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, x);
+    test(y, x, x);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, y);
+    test(y, x, y);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
new file mode 100644
index 0000000..142bcf7
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare> 
+//   requires !SameType<T, Compare> && CopyConstructible<Compare> 
+//   const T&
+//   min(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+    assert(&std::min(a, b, c) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), y);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), x);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
new file mode 100644
index 0000000..4e5da58
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   Iter
+//   min_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::min_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!(*j < *i));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
new file mode 100644
index 0000000..681a0a8
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min_element_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   Iter
+//   min_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::min_element(first, last, std::greater<int>());
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!std::greater<int>()(*j, *i));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
new file mode 100644
index 0000000..286ee26
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T> 
+//   T
+//   min(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+#error min(initializer_list<T> t) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
new file mode 100644
index 0000000..dbbd5e9
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare> 
+//   T
+//   min(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <cassert>
+
+#error min(initializer_list<T> t, Compare comp) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
new file mode 100644
index 0000000..29f2d16
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   pair<const T&, const T&>
+//   minmax(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x, const T& y)
+{
+    std::pair<const T&, const T&> p = std::minmax(a, b);
+    assert(&p.first == &x);
+    assert(&p.second == &y);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x, y);
+    test(y, x, y, x);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, x, y);
+    test(y, x, x, y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, y, x);
+    test(y, x, y, x);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
new file mode 100644
index 0000000..12ebd73
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare> 
+//   requires !SameType<T, Compare> && CopyConstructible<Compare> 
+//   pair<const T&, const T&>
+//   minmax(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x, const T& y)
+{
+    std::pair<const T&, const T&> p = std::minmax(a, b, c);
+    assert(&p.first == &x);
+    assert(&p.second == &y);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x, y);
+    test(y, x, std::greater<int>(), y, x);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), x, y);
+    test(y, x, std::greater<int>(), x, y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), y, x);
+    test(y, x, std::greater<int>(), y, x);
+    }
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
new file mode 100644
index 0000000..afc91e8
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   pair<Iter, Iter> 
+//   minmax_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    std::pair<Iter, Iter> p = std::minmax_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+        {
+            assert(!(*j < *p.first));
+            assert(!(*p.second < *j));
+        }
+    }
+    else
+    {
+        assert(p.first == last);
+        assert(p.second == last);
+    }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+    {
+    const unsigned N = 100;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 5;
+    std::random_shuffle(a, a+N);
+    std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
+    assert(base(p.first) == a);
+    assert(base(p.second) == a+N-1);
+    delete [] a;
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
new file mode 100644
index 0000000..1a49dac
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   pair<Iter, Iter>
+//   minmax_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    typedef std::greater<int> Compare;
+    Compare comp;
+    std::pair<Iter, Iter> p = std::minmax_element(first, last, comp);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+        {
+            assert(!comp(*j, *p.first));
+            assert(!comp(*p.second, *j));
+        }
+    }
+    else
+    {
+        assert(p.first == last);
+        assert(p.second == last);
+    }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N)); 
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+    {
+    const unsigned N = 100;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 5;
+    std::random_shuffle(a, a+N);
+    typedef std::greater<int> Compare;
+    Compare comp;
+    std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
+    assert(base(p.first) == a);
+    assert(base(p.second) == a+N-1);
+    delete [] a;
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
new file mode 100644
index 0000000..310f2eb
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T> 
+//   pair<const T&, const T&>
+//   minmax(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+#error minmax(initializer_list<T> t) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp b/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
new file mode 100644
index 0000000..4ecd21c
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare> 
+//   pair<const T&, const T&>
+//   minmax(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <cassert>
+
+#error minmax(initializer_list<T> t, Compare comp) is not implemented
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
new file mode 100644
index 0000000..8b2127e
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   nth_element(Iter first, Iter nth, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M < N);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::nth_element(array, array+M, array+N);
+    assert(array[M] == M);
+    delete [] array;
+}
+
+void
+test(unsigned N)
+{
+    test_one(N, 0);
+    test_one(N, 1);
+    test_one(N, 2);
+    test_one(N, 3);
+    test_one(N, N/2-1);
+    test_one(N, N/2);
+    test_one(N, N/2+1);
+    test_one(N, N-3);
+    test_one(N, N-2);
+    test_one(N, N-1);
+}
+
+int main()
+{
+    int d = 0;
+    std::nth_element(&d, &d, &d);
+    assert(d == 0);
+    test(256);
+    test(257);
+    test(499);
+    test(500);
+    test(997);
+    test(1000);
+    test(1009);
+}
diff --git a/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
new file mode 100644
index 0000000..5b88ece
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   void
+//   nth_element(Iter first, Iter nth, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M < N);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::nth_element(array, array+M, array+N, std::greater<int>());
+    assert(array[M] == N-M-1);
+    delete [] array;
+}
+
+void
+test(unsigned N)
+{
+    test_one(N, 0);
+    test_one(N, 1);
+    test_one(N, 2);
+    test_one(N, 3);
+    test_one(N, N/2-1);
+    test_one(N, N/2);
+    test_one(N, N/2+1);
+    test_one(N, N-3);
+    test_one(N, N-2);
+    test_one(N, N-1);
+}
+
+int main()
+{
+    int d = 0;
+    std::nth_element(&d, &d, &d);
+    assert(d == 0);
+    test(256);
+    test(257);
+    test(499);
+    test(500);
+    test(997);
+    test(1000);
+    test(1009);
+
+#ifdef _LIBCPP_MOVE
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+    assert(*v[v.size()/2] == v.size()/2);
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp b/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
new file mode 100644
index 0000000..fbd3753
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter> 
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type> 
+//   bool
+//   next_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::next_permutation(Iter(ia), Iter(ia+e));
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+                else
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp b/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
new file mode 100644
index 0000000..9f9f68b
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   bool
+//   next_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    typedef std::greater<int> C;
+    int ia[] = {6, 5, 4, 3, 2, 1};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::next_permutation(Iter(ia), Iter(ia+e), C());
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+                else
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp b/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
new file mode 100644
index 0000000..5b7bfce
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   bool
+//   prev_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {6, 5, 4, 3, 2, 1};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::prev_permutation(Iter(ia), Iter(ia+e));
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+                else
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp b/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
new file mode 100644
index 0000000..ef90774
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   bool
+//   prev_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    typedef std::greater<int> C;
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::prev_permutation(Iter(ia), Iter(ia+e), C());
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+                else
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
new file mode 100644
index 0000000..6d1e492
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2> 
+//   requires HasLess<Iter1::value_type, Iter2::value_type> 
+//         && HasLess<Iter2::value_type, Iter1::value_type>
+//   bool
+//   includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int id[] = {3, 3, 3, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+    assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib)));
+    assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1)));
+    assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb)));
+    assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa)));
+
+
+    assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2)));
+    assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2)));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3)));
+    assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4)));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
new file mode 100644
index 0000000..357c24d
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, typename Compare> 
+//   requires Predicate<Compare, Iter1::value_type, Iter2::value_type> 
+//         && Predicate<Compare, Iter2::value_type, Iter1::value_type> 
+//   bool
+//   includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int id[] = {3, 3, 3, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+    assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), std::less<int>()));
+    assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+
+    assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2), std::less<int>()));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4), std::less<int>()));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
new file mode 100644
index 0000000..93adedf
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && HasLess<InIter2::value_type, InIter1::value_type> 
+//         && HasLess<InIter1::value_type, InIter2::value_type> 
+//   OutIter
+//   set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                  OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+                                     Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    int irr[] = {6};
+    const int srr = sizeof(irr)/sizeof(irr[0]);
+    ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+                             Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == srr);
+    assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
new file mode 100644
index 0000000..7a4ffa7
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter, 
+//          CopyConstructible Compare> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type> 
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type> 
+//   OutIter
+//   set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                  OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+                                     Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    int irr[] = {6};
+    const int srr = sizeof(irr)/sizeof(irr[0]);
+    ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+                             Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == srr);
+    assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
new file mode 100644
index 0000000..035bbbe
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && HasLess<InIter2::value_type, InIter1::value_type> 
+//         && HasLess<InIter1::value_type, InIter2::value_type> 
+//   OutIter
+//   set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                    OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {2, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+                                       Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+                               Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
new file mode 100644
index 0000000..effcb10
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter, 
+//          CopyConstructible Compare> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type> 
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type> 
+//   OutIter
+//   set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                    OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {2, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+                                       Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+                               Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
new file mode 100644
index 0000000..af1d8eb
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && HasLess<InIter2::value_type, InIter1::value_type> 
+//         && HasLess<InIter1::value_type, InIter2::value_type> 
+//   OutIter
+//   set_symmetric_difference(InIter1 first1, InIter1 last1,
+//                            InIter2 first2, InIter2 last2,
+//                            OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+                                               Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+                                       Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
new file mode 100644
index 0000000..c9057b4
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type> 
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type> 
+//   OutIter
+//   set_symmetric_difference(InIter1 first1, InIter1 last1,
+//                            InIter2 first2, InIter2 last2, 
+//                            OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+                                               Iter2(ib), Iter2(ib+sb),
+                                               OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+                                       Iter2(ia), Iter2(ia+sa),
+                                       OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
new file mode 100644
index 0000000..ddde346
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && HasLess<InIter2::value_type, InIter1::value_type> 
+//         && HasLess<InIter1::value_type, InIter2::value_type> 
+//   OutIter
+//   set_union(InIter1 first1, InIter1 last1,
+//             InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+                                Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+                        Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp b/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
new file mode 100644
index 0000000..697551d
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare> 
+//   requires OutputIterator<OutIter, InIter1::reference> 
+//         && OutputIterator<OutIter, InIter2::reference> 
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type> 
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type> 
+//   OutIter
+//   set_union(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//             OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+                                Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+                        Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
new file mode 100644
index 0000000..db7bd5e
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   bool
+//   is_sorted(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a)));
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
new file mode 100644
index 0000000..e7dad90
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   bool
+//   is_sorted(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a)));
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
new file mode 100644
index 0000000..75a757e
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter> 
+//   requires LessThanComparable<Iter::value_type> 
+//   Iter
+//   is_sorted_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a)) == Iter(a));
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
new file mode 100644
index 0000000..974d3dd
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires CopyConstructible<Compare> 
+//   Iter
+//   is_sorted_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a), std::greater<int>()) == Iter(a));
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp b/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
new file mode 100644
index 0000000..df93aa5
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter> 
+//   requires ShuffleIterator<RAIter> 
+//         && OutputIterator<RAIter, InIter::reference> 
+//         && HasLess<InIter::value_type, RAIter::value_type> 
+//         && LessThanComparable<RAIter::value_type> 
+//   RAIter
+//   partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    int* input = new int[N];
+    int* output = new int[M];
+    for (int i = 0; i < N; ++i)
+        input[i] = i;
+    std::random_shuffle(input, input+N);
+    int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M);
+    int* e = output + std::min(N, M);
+    assert(r == e);
+    int i = 0;
+    for (int* x = output; x < e; ++x, ++i)
+        assert(*x == i);
+    delete [] output;
+    delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts<Iter>(N, 0);
+    test_larger_sorts<Iter>(N, 1);
+    test_larger_sorts<Iter>(N, 2);
+    test_larger_sorts<Iter>(N, 3);
+    test_larger_sorts<Iter>(N, N/2-1);
+    test_larger_sorts<Iter>(N, N/2);
+    test_larger_sorts<Iter>(N, N/2+1);
+    test_larger_sorts<Iter>(N, N-2);
+    test_larger_sorts<Iter>(N, N-1);
+    test_larger_sorts<Iter>(N, N);
+    test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_larger_sorts<Iter>(0, 100);
+    test_larger_sorts<Iter>(10);
+    test_larger_sorts<Iter>(256);
+    test_larger_sorts<Iter>(257);
+    test_larger_sorts<Iter>(499);
+    test_larger_sorts<Iter>(500);
+    test_larger_sorts<Iter>(997);
+    test_larger_sorts<Iter>(1000);
+    test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort_copy(&i, &i, &i, &i+5);
+    assert(i == 0);
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
new file mode 100644
index 0000000..c97380c
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter, class Compare> 
+//   requires ShuffleIterator<RAIter> 
+//         && OutputIterator<RAIter, InIter::reference> 
+//         && Predicate<Compare, InIter::value_type, RAIter::value_type> 
+//         && StrictWeakOrder<Compare, RAIter::value_type>} 
+//         && CopyConstructible<Compare> 
+//   RAIter
+//   partial_sort_copy(InIter first, InIter last,
+//                     RAIter result_first, RAIter result_last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    int* input = new int[N];
+    int* output = new int[M];
+    for (int i = 0; i < N; ++i)
+        input[i] = i;
+    std::random_shuffle(input, input+N);
+    int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M,
+                                    std::greater<int>());
+    int* e = output + std::min(N, M);
+    assert(r == e);
+    int i = 0;
+    for (int* x = output; x < e; ++x, ++i)
+        assert(*x == N-i-1);
+    delete [] output;
+    delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts<Iter>(N, 0);
+    test_larger_sorts<Iter>(N, 1);
+    test_larger_sorts<Iter>(N, 2);
+    test_larger_sorts<Iter>(N, 3);
+    test_larger_sorts<Iter>(N, N/2-1);
+    test_larger_sorts<Iter>(N, N/2);
+    test_larger_sorts<Iter>(N, N/2+1);
+    test_larger_sorts<Iter>(N, N-2);
+    test_larger_sorts<Iter>(N, N-1);
+    test_larger_sorts<Iter>(N, N);
+    test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_larger_sorts<Iter>(0, 100);
+    test_larger_sorts<Iter>(10);
+    test_larger_sorts<Iter>(256);
+    test_larger_sorts<Iter>(257);
+    test_larger_sorts<Iter>(499);
+    test_larger_sorts<Iter>(500);
+    test_larger_sorts<Iter>(997);
+    test_larger_sorts<Iter>(1000);
+    test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort_copy(&i, &i, &i, &i+5);
+    assert(i == 0);
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
new file mode 100644
index 0000000..5c4e58c
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   partial_sort(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::partial_sort(array, array+M, array+N);
+    for (int i = 0; i < M; ++i)
+        assert(array[i] == i);
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 0);
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort(&i, &i, &i);
+    assert(i == 0);
+    test_larger_sorts(10);
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
new file mode 100644
index 0000000..66f8a30
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   void
+//   partial_sort(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::partial_sort(array, array+M, array+N, std::greater<int>());
+    for (int i = 0; i < M; ++i)
+        assert(array[i] == N-i-1);
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 0);
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort(&i, &i, &i);
+    assert(i == 0);
+    test_larger_sorts(10);
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+
+#ifdef _LIBCPP_MOVE
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::partial_sort(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+    for (int i = 0; i < v.size()/2; ++i)
+        assert(*v[i] == i);
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
new file mode 100644
index 0000000..79566f9
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+    typedef typename std::iterator_traits<RI>::value_type value_type;
+    if (f != l)
+    {
+        long len = l - f;
+        value_type* save(new value_type[len]);
+        do
+        {
+            std::copy(f, l, save);
+            std::sort(save, save+len);
+            assert(std::is_sorted(save, save+len));
+        } while (std::next_permutation(f, l));
+        delete [] save;
+    }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+    for (RI i = l; i > f + start;)
+    {
+        *--i = start;
+        if (f == i)
+        {
+            test_sort_helper(f, real_last);
+        }
+    if (start > 0)
+        test_sort_driver_driver(f, i, start-1, real_last);
+    }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+    test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+    int ia[sa];
+    for (int i = 0; i < sa; ++i)
+    {
+        test_sort_driver(ia, ia+sa, i);
+    }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M != 0);
+    // create array length N filled with M different numbers
+    int* array = new int[N];
+    int x = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        array[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    // test saw tooth pattern
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test random pattern
+    std::random_shuffle(array, array+N);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test sorted pattern
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse sorted pattern
+    std::reverse(array, array+N);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test swap ranges 2 pattern
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse swap ranges 2 pattern
+    std::reverse(array, array+N);
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    // test null range
+    int d = 0;
+    std::sort(&d, &d);
+    // exhaustively test all possibilities up to length 8
+    test_sort_<1>();
+    test_sort_<2>();
+    test_sort_<3>();
+    test_sort_<4>();
+    test_sort_<5>();
+    test_sort_<6>();
+    test_sort_<7>();
+    test_sort_<8>();
+
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
new file mode 100644
index 0000000..e569151
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   void
+//   sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+
+int main()
+{
+    {
+    std::vector<int> v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i] = i;
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    std::reverse(v.begin(), v.end());
+    assert(std::is_sorted(v.begin(), v.end()));
+    }
+
+#ifdef _LIBCPP_MOVE
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::sort(v.begin(), v.end(), indirect_less());
+    assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+    assert(*v[0] == 0);
+    assert(*v[1] == 1);
+    assert(*v[2] == 2);
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
new file mode 100644
index 0000000..8c55560
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter> 
+//   requires ShuffleIterator<Iter> 
+//         && LessThanComparable<Iter::value_type> 
+//   void
+//   stable_sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+    typedef typename std::iterator_traits<RI>::value_type value_type;
+    if (f != l)
+    {
+        long len = l - f;
+        value_type* save(new value_type[len]);
+        do
+        {
+            std::copy(f, l, save);
+            std::stable_sort(save, save+len);
+            assert(std::is_sorted(save, save+len));
+        } while (std::next_permutation(f, l));
+        delete [] save;
+    }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+    for (RI i = l; i > f + start;)
+    {
+        *--i = start;
+        if (f == i)
+        {
+            test_sort_helper(f, real_last);
+        }
+    if (start > 0)
+        test_sort_driver_driver(f, i, start-1, real_last);
+    }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+    test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+    int ia[sa];
+    for (int i = 0; i < sa; ++i)
+    {
+        test_sort_driver(ia, ia+sa, i);
+    }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M != 0);
+    // create array length N filled with M different numbers
+    int* array = new int[N];
+    int x = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        array[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    // test saw tooth pattern
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test random pattern
+    std::random_shuffle(array, array+N);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test sorted pattern
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse sorted pattern
+    std::reverse(array, array+N);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test swap ranges 2 pattern
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse swap ranges 2 pattern
+    std::reverse(array, array+N);
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    // test null range
+    int d = 0;
+    std::stable_sort(&d, &d);
+    // exhaustively test all possibilities up to length 8
+    test_sort_<1>();
+    test_sort_<2>();
+    test_sort_<3>();
+    test_sort_<4>();
+    test_sort_<5>();
+    test_sort_<6>();
+    test_sort_<7>();
+    test_sort_<8>();
+
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
new file mode 100644
index 0000000..cde19fe
--- /dev/null
+++ b/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare> 
+//   requires ShuffleIterator<Iter> 
+//         && CopyConstructible<Compare> 
+//   void
+//   stable_sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif
+
+struct first_only
+{
+    bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
+    {
+        return x.first < y.first;
+    }
+};
+
+void test()
+{
+    typedef std::pair<int, int> P;
+    const int N = 1000;
+    const int M = 10;
+    std::vector<P> v(N);
+    int x = 0;
+    int ver = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        v[i] = P(x, ver);
+        if (++x == M)
+        {
+            x = 0;
+            ++ver;
+        }
+    }
+    for (int i = 0; i < N - M; i += M)
+    {
+        std::random_shuffle(v.begin() + i, v.begin() + i + M);
+    }
+    std::stable_sort(v.begin(), v.end(), first_only());
+    assert(std::is_sorted(v.begin(), v.end()));
+}
+
+int main()
+{
+    test();
+
+#ifdef _LIBCPP_MOVE
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::stable_sort(v.begin(), v.end(), indirect_less());
+    assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+    assert(*v[0] == 0);
+    assert(*v[1] == 1);
+    assert(*v[2] == 2);
+    }
+#endif
+}
diff --git a/test/algorithms/alg.sorting/nothing_to_do.pass.cpp b/test/algorithms/alg.sorting/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/alg.sorting/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/algorithms.general/nothing_to_do.pass.cpp b/test/algorithms/algorithms.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/algorithms/algorithms.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/algorithms/iterators.h b/test/algorithms/iterators.h
new file mode 100644
index 0000000..01b0e33
--- /dev/null
+++ b/test/algorithms/iterators.h
@@ -0,0 +1,314 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class Iter>
+inline
+Iter
+base(output_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(input_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(forward_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(bidirectional_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+template <class Iter>
+inline
+Iter
+base(random_access_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class Iter>
+inline
+Iter
+base(Iter i)
+{
+    return i;
+}
+
+#endif
diff --git a/test/algorithms/version.pass.cpp b/test/algorithms/version.pass.cpp
new file mode 100644
index 0000000..1e0b0a0
--- /dev/null
+++ b/test/algorithms/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+#include <algorithm>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/Copyable.h b/test/containers/Copyable.h
new file mode 100644
index 0000000..50b3b31
--- /dev/null
+++ b/test/containers/Copyable.h
@@ -0,0 +1,9 @@
+#ifndef COPYABLE_H
+#define COPYABLE_H
+
+class Copyable
+{
+public:
+};
+
+#endif
diff --git a/test/containers/DefaultOnly.h b/test/containers/DefaultOnly.h
new file mode 100644
index 0000000..d40e9c1
--- /dev/null
+++ b/test/containers/DefaultOnly.h
@@ -0,0 +1,26 @@
+#ifndef DEFAULTONLY_H
+#define DEFAULTONLY_H
+
+#include <cassert>
+
+class DefaultOnly
+{
+    int data_;
+
+    DefaultOnly(const DefaultOnly&);
+    DefaultOnly& operator=(const DefaultOnly&);
+public:
+    static int count;
+
+    DefaultOnly() : data_(-1) {++count;}
+    ~DefaultOnly() {data_ = 0; --count;}
+
+    friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ < y.data_;}
+};
+
+int DefaultOnly::count = 0;
+
+#endif
diff --git a/test/containers/Emplaceable.h b/test/containers/Emplaceable.h
new file mode 100644
index 0000000..10a660e
--- /dev/null
+++ b/test/containers/Emplaceable.h
@@ -0,0 +1,45 @@
+#ifndef EMPLACEABLE_H
+#define EMPLACEABLE_H
+
+#ifdef _LIBCPP_MOVE
+
+class Emplaceable
+{
+    Emplaceable(const Emplaceable&);
+    Emplaceable& operator=(const Emplaceable&);
+
+    int int_;
+    double double_;
+public:
+    Emplaceable() : int_(0), double_(0) {}
+    Emplaceable(int i, double d) : int_(i), double_(d) {}
+    Emplaceable(Emplaceable&& x)
+        : int_(x.int_), double_(x.double_)
+            {x.int_ = 0; x.double_ = 0;}
+    Emplaceable& operator=(Emplaceable&& x)
+        {int_ = x.int_; x.int_ = 0;
+         double_ = x.double_; x.double_ = 0;
+         return *this;}
+
+    bool operator==(const Emplaceable& x) const
+        {return int_ == x.int_ && double_ == x.double_;}
+    bool operator<(const Emplaceable& x) const
+        {return int_ < x.int_ || int_ == x.int_ && double_ < x.double_;}
+
+    int get() const {return int_;}
+};
+
+namespace std {
+
+template <>
+struct hash<Emplaceable>
+    : public std::unary_function<Emplaceable, std::size_t>
+{
+    std::size_t operator()(const Emplaceable& x) const {return x.get();}
+};
+
+}
+
+#endif
+
+#endif
diff --git a/test/containers/MoveOnly.h b/test/containers/MoveOnly.h
new file mode 100644
index 0000000..b7d62b7
--- /dev/null
+++ b/test/containers/MoveOnly.h
@@ -0,0 +1,41 @@
+#ifndef MOVEONLY_H
+#define MOVEONLY_H
+
+#ifdef _LIBCPP_MOVE
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+
+    bool operator==(const MoveOnly& x) const {return data_ == x.data_;}    
+    bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}    
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+    : public std::unary_function<MoveOnly, std::size_t>
+{
+    std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif
+
+#endif
diff --git a/test/containers/NotConstructible.h b/test/containers/NotConstructible.h
new file mode 100644
index 0000000..0417736
--- /dev/null
+++ b/test/containers/NotConstructible.h
@@ -0,0 +1,30 @@
+#ifndef NOTCONSTRUCTIBLE_H
+#define NOTCONSTRUCTIBLE_H
+
+#include <functional>
+
+class NotConstructible
+{
+    NotConstructible(const NotConstructible&);
+    NotConstructible& operator=(const NotConstructible&);
+public:
+};
+
+inline
+bool
+operator==(const NotConstructible&, const NotConstructible&)
+{return true;}
+
+namespace std
+{
+
+template <>
+struct hash<NotConstructible>
+    : public std::unary_function<NotConstructible, std::size_t>
+{
+    std::size_t operator()(const NotConstructible&) const {return 0;}
+};
+
+}
+
+#endif
diff --git a/test/containers/associative/map/map.access/at.pass.cpp b/test/containers/associative/map/map.access/at.pass.cpp
new file mode 100644
index 0000000..28d14f6
--- /dev/null
+++ b/test/containers/associative/map/map.access/at.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        m.at(1) = -1.5;
+        assert(m.at(1) == -1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+}
diff --git a/test/containers/associative/map/map.access/empty.pass.cpp b/test/containers/associative/map/map.access/empty.pass.cpp
new file mode 100644
index 0000000..e347fe6
--- /dev/null
+++ b/test/containers/associative/map/map.access/empty.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+}
diff --git a/test/containers/associative/map/map.access/index_key.pass.cpp b/test/containers/associative/map/map.access/index_key.pass.cpp
new file mode 100644
index 0000000..1652169
--- /dev/null
+++ b/test/containers/associative/map/map.access/index_key.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1.5),
+        V(2, 2.5),
+        V(3, 3.5),
+        V(4, 4.5),
+        V(5, 5.5),
+        V(7, 7.5),
+        V(8, 8.5),
+    };
+    std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 7);
+    assert(m[1] == 1.5);
+    assert(m.size() == 7);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 7);
+    assert(m[6] == 0);
+    assert(m.size() == 8);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 8);
+}
diff --git a/test/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/containers/associative/map/map.access/index_rv_key.pass.cpp
new file mode 100644
index 0000000..6c2766d
--- /dev/null
+++ b/test/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](key_type&& k);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<MoveOnly, double> V;
+    std::map<MoveOnly, double> m;
+    assert(m.size() == 0);
+    assert(m[1] == 0.0);
+    assert(m.size() == 1);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 1);
+    assert(m[6] == 0);
+    assert(m.size() == 2);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 2);
+#endif
+}
diff --git a/test/containers/associative/map/map.access/iterator.pass.cpp b/test/containers/associative/map/map.access/iterator.pass.cpp
new file mode 100644
index 0000000..0eefb75
--- /dev/null
+++ b/test/containers/associative/map/map.access/iterator.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+// 
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+// 
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::map<int, double>::iterator i = m.begin();
+        std::map<int, double>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+            i->second = 2.5;
+            assert(i->second == 2.5);
+        }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::map<int, double>::const_iterator i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+        }
+    }
+}
diff --git a/test/containers/associative/map/map.access/max_size.pass.cpp b/test/containers/associative/map/map.access/max_size.pass.cpp
new file mode 100644
index 0000000..ee11af2
--- /dev/null
+++ b/test/containers/associative/map/map.access/max_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.max_size() != 0);
+}
diff --git a/test/containers/associative/map/map.access/size.pass.cpp b/test/containers/associative/map/map.access/size.pass.cpp
new file mode 100644
index 0000000..edbbdd9
--- /dev/null
+++ b/test/containers/associative/map/map.access/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+}
diff --git a/test/containers/associative/map/map.cons/alloc.pass.cpp b/test/containers/associative/map/map.cons/alloc.pass.cpp
new file mode 100644
index 0000000..63d7b3b
--- /dev/null
+++ b/test/containers/associative/map/map.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..1947e5b
--- /dev/null
+++ b/test/containers/associative/map/map.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {20, 1},
+                            };
+    m = 
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/compare.pass.cpp b/test/containers/associative/map/map.cons/compare.pass.cpp
new file mode 100644
index 0000000..0235a34
--- /dev/null
+++ b/test/containers/associative/map/map.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/test/containers/associative/map/map.cons/compare_alloc.pass.cpp b/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..924a906
--- /dev/null
+++ b/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/map/map.cons/copy.pass.cpp b/test/containers/associative/map/map.cons/copy.pass.cpp
new file mode 100644
index 0000000..a26c015
--- /dev/null
+++ b/test/containers/associative/map/map.cons/copy.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/copy_alloc.pass.cpp b/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..89337fe
--- /dev/null
+++ b/test/containers/associative/map/map.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::map<int, double, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 3);
+    assert(distance(mo.begin(), mo.end()) == 3);
+    assert(*mo.begin() == V(1, 1));
+    assert(*next(mo.begin()) == V(2, 1));
+    assert(*next(mo.begin(), 2) == V(3, 1));
+}
diff --git a/test/containers/associative/map/map.cons/copy_assign.pass.cpp b/test/containers/associative/map/map.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..c350d49
--- /dev/null
+++ b/test/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+}
diff --git a/test/containers/associative/map/map.cons/default.pass.cpp b/test/containers/associative/map/map.cons/default.pass.cpp
new file mode 100644
index 0000000..b630c1e
--- /dev/null
+++ b/test/containers/associative/map/map.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    std::map<int, double> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+}
diff --git a/test/containers/associative/map/map.cons/initializer_list.pass.cpp b/test/containers/associative/map/map.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..0d139e0
--- /dev/null
+++ b/test/containers/associative/map/map.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..616d8af
--- /dev/null
+++ b/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m({
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                               }, C(3));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..bfde3f7
--- /dev/null
+++ b/test/containers/associative/map/map.cons/initializer_list_compare_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m({
+                                   {1, 1},
+                                   {1, 1.5},
+                                   {1, 2},
+                                   {2, 1},
+                                   {2, 1.5},
+                                   {2, 2},
+                                   {3, 1},
+                                   {3, 1.5},
+                                   {3, 2}
+                                  }, C(3), A(6));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+    assert(m.get_allocator() == A(6));
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/iter_iter.pass.cpp b/test/containers/associative/map/map.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..d69249d
--- /dev/null
+++ b/test/containers/associative/map/map.cons/iter_iter.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+}
diff --git a/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..6391c69
--- /dev/null
+++ b/test/containers/associative/map/map.cons/iter_iter_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+}
diff --git a/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 0000000..86f86b2
--- /dev/null
+++ b/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last,
+//         const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    assert(m.get_allocator() == A(7));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+}
diff --git a/test/containers/associative/map/map.cons/move.pass.cpp b/test/containers/associative/map/map.cons/move.pass.cpp
new file mode 100644
index 0000000..4ead980
--- /dev/null
+++ b/test/containers/associative/map/map.cons/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(C(5), A(7));
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/move_alloc.pass.cpp b/test/containers/associative/map/map.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..fbb88f6
--- /dev/null
+++ b/test/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.cons/move_assign.pass.cpp b/test/containers/associative/map/map.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..6222ce6
--- /dev/null
+++ b/test/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.modifiers/clear.pass.cpp b/test/containers/associative/map/map.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..1c0fd4e
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/emplace.pass.cpp b/test/containers/associative/map/map.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..42abd81
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+//   pair<iterator, bool> emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::map<int, DefaultOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(1);
+        assert(r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(1);
+        assert(!r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(2);
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(1, 2, 3.5);
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(1, 2, 3.5);
+        assert(!r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..58827fd
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::map<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.end());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.end(), 1);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.end(), 1);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), 2);
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.end(), 1, 2, 3.5);
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.end(), 1, 2, 3.5);
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..045f820
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..d7e375c
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/erase_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/erase_key.pass.cpp b/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..6a18419
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type R;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        R s = m.erase(9);
+        assert(s == 0);
+        assert(m.size() == 8);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        s = m.erase(4);
+        assert(m.size() == 7);
+        assert(s == 1);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        s = m.erase(1);
+        assert(m.size() == 6);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        s = m.erase(8);
+        assert(m.size() == 5);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        s = m.erase(3);
+        assert(m.size() == 4);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        s = m.erase(6);
+        assert(m.size() == 3);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        s = m.erase(7);
+        assert(m.size() == 2);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        s = m.erase(2);
+        assert(m.size() == 1);
+        assert(s == 1);
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        s = m.erase(5);
+        assert(m.size() == 0);
+        assert(s == 1);
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
new file mode 100644
index 0000000..41a80ec
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..ff14a3e
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    m.insert({
+                 {2, 1},
+                 {2, 1.5},
+                 {2, 2},
+             });
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+#endif
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..d2f4d7e
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..10bf39c
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 1);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+    }
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..5aaffad
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+//     iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::map<int, MoveOnly> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.end(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
new file mode 100644
index 0000000..44fa497
--- /dev/null
+++ b/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+//   pair<iterator, bool> insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::map<int, MoveOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/map/map.ops/count.pass.cpp b/test/containers/associative/map/map.ops/count.pass.cpp
new file mode 100644
index 0000000..643d9a8
--- /dev/null
+++ b/test/containers/associative/map/map.ops/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+}
diff --git a/test/containers/associative/map/map.ops/equal_range.pass.cpp b/test/containers/associative/map/map.ops/equal_range.pass.cpp
new file mode 100644
index 0000000..527a70b
--- /dev/null
+++ b/test/containers/associative/map/map.ops/equal_range.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/map/map.ops/find.pass.cpp b/test/containers/associative/map/map.ops/find.pass.cpp
new file mode 100644
index 0000000..4566ce6
--- /dev/null
+++ b/test/containers/associative/map/map.ops/find.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/map/map.ops/lower_bound.pass.cpp b/test/containers/associative/map/map.ops/lower_bound.pass.cpp
new file mode 100644
index 0000000..11d58e0
--- /dev/null
+++ b/test/containers/associative/map/map.ops/lower_bound.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/map/map.ops/upper_bound.pass.cpp b/test/containers/associative/map/map.ops/upper_bound.pass.cpp
new file mode 100644
index 0000000..1acb86a
--- /dev/null
+++ b/test/containers/associative/map/map.ops/upper_bound.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/map/map.special/member_swap.pass.cpp b/test/containers/associative/map/map.special/member_swap.pass.cpp
new file mode 100644
index 0000000..cf7eb53
--- /dev/null
+++ b/test/containers/associative/map/map.special/member_swap.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void swap(map& m);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+}
diff --git a/test/containers/associative/map/map.special/non_member_swap.pass.cpp b/test/containers/associative/map/map.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..516a6dc
--- /dev/null
+++ b/test/containers/associative/map/map.special/non_member_swap.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class Key, class T, class Compare, class Allocator>
+//   void
+//   swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "../../../test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::map<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::map<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/associative/map/types.pass.cpp b/test/containers/associative/map/types.pass.cpp
new file mode 100644
index 0000000..7898eae
--- /dev/null
+++ b/test/containers/associative/map/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+//           class Allocator = allocator<pair<const Key, T>>>
+// class map
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef T                                        mapped_type;
+//     typedef pair<const key_type, mapped_type>        value_type;
+//     typedef Compare                                  key_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <map>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::map<int, double>::key_type, int>::value), "");
+    static_assert((std::is_same<std::map<int, double>::mapped_type, double>::value), "");
+    static_assert((std::is_same<std::map<int, double>::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<std::map<int, double>::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::map<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<std::map<int, double>::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<std::map<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<std::map<int, double>::pointer, std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<std::map<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<std::map<int, double>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::map<int, double>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/containers/associative/map/version.pass.cpp b/test/containers/associative/map/version.pass.cpp
new file mode 100644
index 0000000..f4ba29c
--- /dev/null
+++ b/test/containers/associative/map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+#include <map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/associative/multimap/empty.pass.cpp b/test/containers/associative/multimap/empty.pass.cpp
new file mode 100644
index 0000000..f837281
--- /dev/null
+++ b/test/containers/associative/multimap/empty.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+}
diff --git a/test/containers/associative/multimap/iterator.pass.cpp b/test/containers/associative/multimap/iterator.pass.cpp
new file mode 100644
index 0000000..70b95f5
--- /dev/null
+++ b/test/containers/associative/multimap/iterator.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+// 
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+// 
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multimap<int, double>::iterator i = m.begin();
+        std::multimap<int, double>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+                i->second = 2.5;
+                assert(i->second == 2.5);
+            }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multimap<int, double>::const_iterator i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+            }
+    }
+}
diff --git a/test/containers/associative/multimap/max_size.pass.cpp b/test/containers/associative/multimap/max_size.pass.cpp
new file mode 100644
index 0000000..e5c7ff0
--- /dev/null
+++ b/test/containers/associative/multimap/max_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.max_size() != 0);
+}
diff --git a/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp
new file mode 100644
index 0000000..d51a2ae
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..20172fe
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m = {{20, 1}};
+    m = 
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/compare.pass.cpp b/test/containers/associative/multimap/multimap.cons/compare.pass.cpp
new file mode 100644
index 0000000..573ba1f
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..9bf8e61
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/copy.pass.cpp b/test/containers/associative/multimap/multimap.cons/copy.pass.cpp
new file mode 100644
index 0000000..95fdf63
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/copy.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..d4a5bb5
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::multimap<int, double, C, A> m(mo, A(3));
+    assert(m == mo);
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..ca16383
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.cons/default.pass.cpp b/test/containers/associative/multimap/multimap.cons/default.pass.cpp
new file mode 100644
index 0000000..648331d
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap();
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    std::multimap<int, double> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+}
diff --git a/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..8f2444f
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..5ecea2f
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::multimap<int, double, Cmp> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4)
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..ef4d4b3
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<std::pair<const int, double> > A;
+    typedef std::multimap<int, double, Cmp, A> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4), A(5)
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+    assert(m.get_allocator() == A(5));
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..689c4ff
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..3dcfa4c
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last,
+//              const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 0000000..c976a14
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last,
+//              const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    assert(m.get_allocator() == A(7));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+}
diff --git a/test/containers/associative/multimap/multimap.cons/move.pass.cpp b/test/containers/associative/multimap/multimap.cons/move.pass.cpp
new file mode 100644
index 0000000..857d390
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::pair<const int, double> V;
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(C(5), A(7));
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(1, 1.5));
+        assert(*next(m.begin(), 2) == V(1, 2));
+        assert(*next(m.begin(), 3) == V(2, 1));
+        assert(*next(m.begin(), 4) == V(2, 1.5));
+        assert(*next(m.begin(), 5) == V(2, 2));
+        assert(*next(m.begin(), 6) == V(3, 1));
+        assert(*next(m.begin(), 7) == V(3, 1.5));
+        assert(*next(m.begin(), 8) == V(3, 2));
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..a70e19f
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..ee72dc5
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..fe880e6
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..2544481
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+//   iterator emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multimap<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(1);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(1);
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(2);
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(1, 2, 3.5);
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(1, 3, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..0e71b45
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multimap<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.cend(), 1);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.cend(), 1);
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), 2);
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.cbegin(), 1, 2, 3.5);
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), 1, 3, 3.5);
+        assert(r == m.begin());
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..830f338
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1.5);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 2);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1.5);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 7);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1.5);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 6);
+        assert(i == prev(m.end()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 5);
+        assert(i == next(m.begin()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 3);
+        assert(next(m.begin(), 1)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 1);
+        assert(i == m.end());
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..8896645
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..2a9d578
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 0);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(1);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
new file mode 100644
index 0000000..81d752d
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..82e7136
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 2},
+               {2, 1},
+               {2, 2},
+               {3, 1},
+               {3, 2}
+           };
+    m.insert(
+               {
+                   {1, 1.5},
+                   {2, 1.5},
+                   {3, 1.5},
+               }
+            );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 2));
+    assert(*++i == V(3, 1.5));
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..fd13665
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+        assert(r == prev(m.end(), 2));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 4.5);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..4d2ddf9
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 2);
+        assert(next(m.begin(), 5)->second == 2);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 1.5);
+        assert(next(m.begin(), 8)->first == 3);
+        assert(next(m.begin(), 8)->second == 2);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..5429c16
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+//     iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multimap<int, MoveOnly> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.cend(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.cend(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.cend(), P(3, 2));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 2);
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
new file mode 100644
index 0000000..dc378b1
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+//   iterator insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multimap<int, MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/multimap/multimap.ops/count.pass.cpp b/test/containers/associative/multimap/multimap.ops/count.pass.cpp
new file mode 100644
index 0000000..de49dab
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.ops/count.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 3);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 3);
+        r = m.count(10);
+        assert(r == 0);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
new file mode 100644
index 0000000..bcfe4cb
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// pair<iterator, iterator>             equal_range(const key_type& k);
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/containers/associative/multimap/multimap.ops/find.pass.cpp
new file mode 100644
index 0000000..a5ea90f
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.ops/find.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
new file mode 100644
index 0000000..2d34ba1
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
new file mode 100644
index 0000000..ed83342
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp
new file mode 100644
index 0000000..f623c61
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void swap(multimap& m);
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+}
diff --git a/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..c37fc60
--- /dev/null
+++ b/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class Key, class T, class Compare, class Allocator>
+//   void
+//   swap(multimap<Key, T, Compare, Allocator>& x, multimap<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "../../../test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multimap<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multimap<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/associative/multimap/size.pass.cpp b/test/containers/associative/multimap/size.pass.cpp
new file mode 100644
index 0000000..e60b101
--- /dev/null
+++ b/test/containers/associative/multimap/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+int main()
+{
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+}
diff --git a/test/containers/associative/multimap/types.pass.cpp b/test/containers/associative/multimap/types.pass.cpp
new file mode 100644
index 0000000..b805a70
--- /dev/null
+++ b/test/containers/associative/multimap/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+//           class Allocator = allocator<pair<const Key, T>>>
+// class multimap
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef T                                        mapped_type;
+//     typedef pair<const key_type, mapped_type>        value_type;
+//     typedef Compare                                  key_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <map>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::multimap<int, double>::key_type, int>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::mapped_type, double>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::pointer, std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::multimap<int, double>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/containers/associative/multiset/clear.pass.cpp b/test/containers/associative/multiset/clear.pass.cpp
new file mode 100644
index 0000000..c112aec
--- /dev/null
+++ b/test/containers/associative/multiset/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+}
diff --git a/test/containers/associative/multiset/count.pass.cpp b/test/containers/associative/multiset/count.pass.cpp
new file mode 100644
index 0000000..930aedb
--- /dev/null
+++ b/test/containers/associative/multiset/count.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 4);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 2);
+        r = m.count(10);
+        assert(r == 0);
+    }
+}
diff --git a/test/containers/associative/multiset/emplace.pass.cpp b/test/containers/associative/multiset/emplace.pass.cpp
new file mode 100644
index 0000000..b1520e9
--- /dev/null
+++ b/test/containers/associative/multiset/emplace.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+//   iterator emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multiset<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace();
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multiset<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace(2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace(2, 3.5);
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/emplace_hint.pass.cpp b/test/containers/associative/multiset/emplace_hint.pass.cpp
new file mode 100644
index 0000000..4562249
--- /dev/null
+++ b/test/containers/associative/multiset/emplace_hint.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multiset<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace_hint(m.cbegin());
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multiset<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace_hint(m.cend(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 3);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/empty.pass.cpp b/test/containers/associative/multiset/empty.pass.cpp
new file mode 100644
index 0000000..cc40522
--- /dev/null
+++ b/test/containers/associative/multiset/empty.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+}
diff --git a/test/containers/associative/multiset/equal_range.pass.cpp b/test/containers/associative/multiset/equal_range.pass.cpp
new file mode 100644
index 0000000..7abfa92
--- /dev/null
+++ b/test/containers/associative/multiset/equal_range.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+}
diff --git a/test/containers/associative/multiset/erase_iter.pass.cpp b/test/containers/associative/multiset/erase_iter.pass.cpp
new file mode 100644
index 0000000..0551ec9
--- /dev/null
+++ b/test/containers/associative/multiset/erase_iter.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/multiset/erase_iter_iter.pass.cpp b/test/containers/associative/multiset/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..58eed89
--- /dev/null
+++ b/test/containers/associative/multiset/erase_iter_iter.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/multiset/erase_key.pass.cpp b/test/containers/associative/multiset/erase_key.pass.cpp
new file mode 100644
index 0000000..3527347
--- /dev/null
+++ b/test/containers/associative/multiset/erase_key.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            3,
+            3,
+            3,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(6);
+        assert(m.size() == 9);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 5);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 7);
+        assert(*next(m.begin(), 8) == 7);
+
+        i = m.erase(5);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 7);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 7);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+}
diff --git a/test/containers/associative/multiset/find.pass.cpp b/test/containers/associative/multiset/find.pass.cpp
new file mode 100644
index 0000000..3cb1c51
--- /dev/null
+++ b/test/containers/associative/multiset/find.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/multiset/insert_cv.pass.cpp b/test/containers/associative/multiset/insert_cv.pass.cpp
new file mode 100644
index 0000000..f17b418
--- /dev/null
+++ b/test/containers/associative/multiset/insert_cv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+}
diff --git a/test/containers/associative/multiset/insert_initializer_list.pass.cpp b/test/containers/associative/multiset/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..3cf7bf1
--- /dev/null
+++ b/test/containers/associative/multiset/insert_initializer_list.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+#endif
+}
diff --git a/test/containers/associative/multiset/insert_iter_cv.pass.cpp b/test/containers/associative/multiset/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..a99e052
--- /dev/null
+++ b/test/containers/associative/multiset/insert_iter_cv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+}
diff --git a/test/containers/associative/multiset/insert_iter_iter.pass.cpp b/test/containers/associative/multiset/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..332574b
--- /dev/null
+++ b/test/containers/associative/multiset/insert_iter_iter.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    }
+}
diff --git a/test/containers/associative/multiset/insert_iter_rv.pass.cpp b/test/containers/associative/multiset/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..f1179e7
--- /dev/null
+++ b/test/containers/associative/multiset/insert_iter_rv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multiset<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/insert_rv.pass.cpp b/test/containers/associative/multiset/insert_rv.pass.cpp
new file mode 100644
index 0000000..1f722e4
--- /dev/null
+++ b/test/containers/associative/multiset/insert_rv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::multiset<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/iterator.pass.cpp b/test/containers/associative/multiset/iterator.pass.cpp
new file mode 100644
index 0000000..4a13f6b
--- /dev/null
+++ b/test/containers/associative/multiset/iterator.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+// 
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+// 
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multiset<int>::iterator i = m.begin();
+        std::multiset<int>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multiset<int, double>::const_iterator i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+}
diff --git a/test/containers/associative/multiset/lower_bound.pass.cpp b/test/containers/associative/multiset/lower_bound.pass.cpp
new file mode 100644
index 0000000..ec96e13
--- /dev/null
+++ b/test/containers/associative/multiset/lower_bound.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(5);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(5);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+}
diff --git a/test/containers/associative/multiset/max_size.pass.cpp b/test/containers/associative/multiset/max_size.pass.cpp
new file mode 100644
index 0000000..0e0a8df
--- /dev/null
+++ b/test/containers/associative/multiset/max_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.max_size() != 0);
+}
diff --git a/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp
new file mode 100644
index 0000000..df8fd06
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<int> A;
+    std::multiset<int, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..c47f687
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/compare.pass.cpp b/test/containers/associative/multiset/multiset.cons/compare.pass.cpp
new file mode 100644
index 0000000..7cba6d8
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// explicit multiset(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::multiset<int, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..c2d4232
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<int> A;
+    std::multiset<int, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/multiset/multiset.cons/copy.pass.cpp b/test/containers/associative/multiset/multiset.cons/copy.pass.cpp
new file mode 100644
index 0000000..8fb6b4a
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..6d60890
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::multiset<int, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 9);
+    assert(distance(mo.begin(), mo.end()) == 9);
+    assert(*next(mo.begin(), 0) == 1);
+    assert(*next(mo.begin(), 1) == 1);
+    assert(*next(mo.begin(), 2) == 1);
+    assert(*next(mo.begin(), 3) == 2);
+    assert(*next(mo.begin(), 4) == 2);
+    assert(*next(mo.begin(), 5) == 2);
+    assert(*next(mo.begin(), 6) == 3);
+    assert(*next(mo.begin(), 7) == 3);
+    assert(*next(mo.begin(), 8) == 3);
+}
diff --git a/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..b52ed3b
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(const multiset& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+}
diff --git a/test/containers/associative/multiset/multiset.cons/default.pass.cpp b/test/containers/associative/multiset/multiset.cons/default.pass.cpp
new file mode 100644
index 0000000..9f06fa9
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset();
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    std::multiset<int> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+}
diff --git a/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..802c659
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp b/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..d5af128
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::multiset<int, Cmp> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..7d78a2e
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<int> A;
+    typedef std::multiset<int, Cmp, A> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+    assert(m.get_allocator() == A(4));
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..d7855f7
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::multiset<V> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+}
diff --git a/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..0b6cc43
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last,
+//         const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    typedef test_allocator<V> A;
+    std::multiset<V, C, A> m(input_iterator<const V*>(ar),
+                        input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+                        C(5), A(7));
+    assert(m.value_comp() == C(5));
+    assert(m.get_allocator() == A(7));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+}
diff --git a/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp b/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..06044ea
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    std::multiset<V, C> m(input_iterator<const V*>(ar),
+                     input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+    assert(m.value_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+}
diff --git a/test/containers/associative/multiset/multiset.cons/move.pass.cpp b/test/containers/associative/multiset/multiset.cons/move.pass.cpp
new file mode 100644
index 0000000..60ec113
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/move.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int V;
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(C(5), A(7));
+        std::multiset<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..c078bc5
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..e4de43b
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp
new file mode 100644
index 0000000..fdcfb26
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+}
diff --git a/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp b/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..b4b0d06
--- /dev/null
+++ b/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+#include "../../../test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/associative/multiset/size.pass.cpp b/test/containers/associative/multiset/size.pass.cpp
new file mode 100644
index 0000000..7431701
--- /dev/null
+++ b/test/containers/associative/multiset/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(2));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+}
diff --git a/test/containers/associative/multiset/types.pass.cpp b/test/containers/associative/multiset/types.pass.cpp
new file mode 100644
index 0000000..f1ec413
--- /dev/null
+++ b/test/containers/associative/multiset/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+//           class Allocator = allocator<Key>>
+// class multiset
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef key_type                                 value_type;
+//     typedef Compare                                  key_compare;
+//     typedef key_compare                              value_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <set>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::multiset<int>::key_type, int>::value), "");
+    static_assert((std::is_same<std::multiset<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::multiset<int>::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::multiset<int>::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::multiset<int>::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<std::multiset<int>::reference, int&>::value), "");
+    static_assert((std::is_same<std::multiset<int>::const_reference, const int&>::value), "");
+    static_assert((std::is_same<std::multiset<int>::pointer, int*>::value), "");
+    static_assert((std::is_same<std::multiset<int>::const_pointer, const int*>::value), "");
+    static_assert((std::is_same<std::multiset<int>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::multiset<int>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/containers/associative/multiset/upper_bound.pass.cpp b/test/containers/associative/multiset/upper_bound.pass.cpp
new file mode 100644
index 0000000..2244e7c
--- /dev/null
+++ b/test/containers/associative/multiset/upper_bound.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+}
diff --git a/test/containers/associative/set/clear.pass.cpp b/test/containers/associative/set/clear.pass.cpp
new file mode 100644
index 0000000..b392521
--- /dev/null
+++ b/test/containers/associative/set/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+}
diff --git a/test/containers/associative/set/count.pass.cpp b/test/containers/associative/set/count.pass.cpp
new file mode 100644
index 0000000..b46242e
--- /dev/null
+++ b/test/containers/associative/set/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+}
diff --git a/test/containers/associative/set/emplace.pass.cpp b/test/containers/associative/set/emplace.pass.cpp
new file mode 100644
index 0000000..35f9856
--- /dev/null
+++ b/test/containers/associative/set/emplace.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+//   pair<iterator, bool> emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::set<DefaultOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace();
+        assert(!r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::set<Emplaceable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace(2, 3.5);
+        assert(r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r.first == Emplaceable(2, 3.5));
+        r = m.emplace(2, 3.5);
+        assert(!r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r.first == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::set<int> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/emplace_hint.pass.cpp b/test/containers/associative/set/emplace_hint.pass.cpp
new file mode 100644
index 0000000..af0439c
--- /dev/null
+++ b/test/containers/associative/set/emplace_hint.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "../../DefaultOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::set<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace_hint(m.cbegin());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::set<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace_hint(m.cend(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::set<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/empty.pass.cpp b/test/containers/associative/set/empty.pass.cpp
new file mode 100644
index 0000000..a036656
--- /dev/null
+++ b/test/containers/associative/set/empty.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::set<int> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+}
diff --git a/test/containers/associative/set/equal_range.pass.cpp b/test/containers/associative/set/equal_range.pass.cpp
new file mode 100644
index 0000000..7c39821
--- /dev/null
+++ b/test/containers/associative/set/equal_range.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/set/erase_iter.pass.cpp b/test/containers/associative/set/erase_iter.pass.cpp
new file mode 100644
index 0000000..f5a698d
--- /dev/null
+++ b/test/containers/associative/set/erase_iter.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/set/erase_iter_iter.pass.cpp b/test/containers/associative/set/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..1d02040
--- /dev/null
+++ b/test/containers/associative/set/erase_iter_iter.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+}
diff --git a/test/containers/associative/set/erase_key.pass.cpp b/test/containers/associative/set/erase_key.pass.cpp
new file mode 100644
index 0000000..0c4c7b4
--- /dev/null
+++ b/test/containers/associative/set/erase_key.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(9);
+        assert(m.size() == 8);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(4);
+        assert(m.size() == 7);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(1);
+        assert(m.size() == 6);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(8);
+        assert(m.size() == 5);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 4);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(6);
+        assert(m.size() == 3);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 2);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(2);
+        assert(m.size() == 1);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(5);
+        assert(m.size() == 0);
+        assert(i == 1);
+    }
+}
diff --git a/test/containers/associative/set/find.pass.cpp b/test/containers/associative/set/find.pass.cpp
new file mode 100644
index 0000000..885d6aa
--- /dev/null
+++ b/test/containers/associative/set/find.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/set/insert_cv.pass.cpp b/test/containers/associative/set/insert_cv.pass.cpp
new file mode 100644
index 0000000..8fcc57d
--- /dev/null
+++ b/test/containers/associative/set/insert_cv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+}
diff --git a/test/containers/associative/set/insert_initializer_list.pass.cpp b/test/containers/associative/set/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..089238b
--- /dev/null
+++ b/test/containers/associative/set/insert_initializer_list.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+#endif
+}
diff --git a/test/containers/associative/set/insert_iter_cv.pass.cpp b/test/containers/associative/set/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..3940ff3
--- /dev/null
+++ b/test/containers/associative/set/insert_iter_cv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+}
diff --git a/test/containers/associative/set/insert_iter_iter.pass.cpp b/test/containers/associative/set/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..dc7df93
--- /dev/null
+++ b/test/containers/associative/set/insert_iter_iter.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    }
+}
diff --git a/test/containers/associative/set/insert_iter_rv.pass.cpp b/test/containers/associative/set/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..4cbc2f9
--- /dev/null
+++ b/test/containers/associative/set/insert_iter_rv.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::set<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/insert_rv.pass.cpp b/test/containers/associative/set/insert_rv.pass.cpp
new file mode 100644
index 0000000..9605596
--- /dev/null
+++ b/test/containers/associative/set/insert_rv.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::set<MoveOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/iterator.pass.cpp b/test/containers/associative/set/iterator.pass.cpp
new file mode 100644
index 0000000..c94590c
--- /dev/null
+++ b/test/containers/associative/set/iterator.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+// 
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+// 
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::set<int>::iterator i = m.begin();
+        std::set<int>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::set<int, double>::const_iterator i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+}
diff --git a/test/containers/associative/set/lower_bound.pass.cpp b/test/containers/associative/set/lower_bound.pass.cpp
new file mode 100644
index 0000000..7f4b0e3
--- /dev/null
+++ b/test/containers/associative/set/lower_bound.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/set/max_size.pass.cpp b/test/containers/associative/set/max_size.pass.cpp
new file mode 100644
index 0000000..4f4861a
--- /dev/null
+++ b/test/containers/associative/set/max_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::set<int> M;
+    M m;
+    assert(m.max_size() != 0);
+}
diff --git a/test/containers/associative/set/set.cons/alloc.pass.cpp b/test/containers/associative/set/set.cons/alloc.pass.cpp
new file mode 100644
index 0000000..ec64902
--- /dev/null
+++ b/test/containers/associative/set/set.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<int> A;
+    std::set<int, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..5d1836b
--- /dev/null
+++ b/test/containers/associative/set/set.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/compare.pass.cpp b/test/containers/associative/set/set.cons/compare.pass.cpp
new file mode 100644
index 0000000..00d3b92
--- /dev/null
+++ b/test/containers/associative/set/set.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// explicit set(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::set<int, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/test/containers/associative/set/set.cons/compare_alloc.pass.cpp b/test/containers/associative/set/set.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..0b1d7a2
--- /dev/null
+++ b/test/containers/associative/set/set.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<int> A;
+    std::set<int, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/test/containers/associative/set/set.cons/copy.pass.cpp b/test/containers/associative/set/set.cons/copy.pass.cpp
new file mode 100644
index 0000000..3ff1130
--- /dev/null
+++ b/test/containers/associative/set/set.cons/copy.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/copy_alloc.pass.cpp b/test/containers/associative/set/set.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..c0b58ea
--- /dev/null
+++ b/test/containers/associative/set/set.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::set<int, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 3);
+    assert(distance(mo.begin(), mo.end()) == 3);
+    assert(*mo.begin() == 1);
+    assert(*next(mo.begin()) == 2);
+    assert(*next(mo.begin(), 2) == 3);
+}
diff --git a/test/containers/associative/set/set.cons/copy_assign.pass.cpp b/test/containers/associative/set/set.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..17e18de
--- /dev/null
+++ b/test/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(const set& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+}
diff --git a/test/containers/associative/set/set.cons/default.pass.cpp b/test/containers/associative/set/set.cons/default.pass.cpp
new file mode 100644
index 0000000..57c3243
--- /dev/null
+++ b/test/containers/associative/set/set.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set();
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    std::set<int> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+}
diff --git a/test/containers/associative/set/set.cons/initializer_list.pass.cpp b/test/containers/associative/set/set.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..dce2427
--- /dev/null
+++ b/test/containers/associative/set/set.cons/initializer_list.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp b/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..b11da1c
--- /dev/null
+++ b/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::set<int, Cmp> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..12c3f44
--- /dev/null
+++ b/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<int> A;
+    typedef std::set<int, Cmp, A> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+    assert(m.get_allocator() == A(4));
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/iter_iter.pass.cpp b/test/containers/associative/set/set.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..d62c7bc
--- /dev/null
+++ b/test/containers/associative/set/set.cons/iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::set<V> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+}
diff --git a/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..b84bece
--- /dev/null
+++ b/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last,
+//         const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    typedef test_allocator<V> A;
+    std::set<V, C, A> m(input_iterator<const V*>(ar),
+                        input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+                        C(5), A(7));
+    assert(m.value_comp() == C(5));
+    assert(m.get_allocator() == A(7));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+}
diff --git a/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp b/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..8466eef
--- /dev/null
+++ b/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    std::set<V, C> m(input_iterator<const V*>(ar),
+                     input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+    assert(m.value_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+}
diff --git a/test/containers/associative/set/set.cons/move.pass.cpp b/test/containers/associative/set/set.cons/move.pass.cpp
new file mode 100644
index 0000000..4859b24
--- /dev/null
+++ b/test/containers/associative/set/set.cons/move.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int V;
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(C(5), A(7));
+        std::set<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/move_alloc.pass.cpp b/test/containers/associative/set/set.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..1207079
--- /dev/null
+++ b/test/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/set/set.cons/move_assign.pass.cpp b/test/containers/associative/set/set.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..d9261f0
--- /dev/null
+++ b/test/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/test/containers/associative/set/set.special/member_swap.pass.cpp b/test/containers/associative/set/set.special/member_swap.pass.cpp
new file mode 100644
index 0000000..74b2a2b
--- /dev/null
+++ b/test/containers/associative/set/set.special/member_swap.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+}
diff --git a/test/containers/associative/set/set.special/non_member_swap.pass.cpp b/test/containers/associative/set/set.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..bca7562
--- /dev/null
+++ b/test/containers/associative/set/set.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+#include "../../../test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multiset<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multiset<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/associative/set/size.pass.cpp b/test/containers/associative/set/size.pass.cpp
new file mode 100644
index 0000000..a0c2458
--- /dev/null
+++ b/test/containers/associative/set/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef std::set<int> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+}
diff --git a/test/containers/associative/set/types.pass.cpp b/test/containers/associative/set/types.pass.cpp
new file mode 100644
index 0000000..574825e
--- /dev/null
+++ b/test/containers/associative/set/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+//           class Allocator = allocator<Key>>
+// class set
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef key_type                                 value_type;
+//     typedef Compare                                  key_compare;
+//     typedef key_compare                              value_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <set>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::set<int>::key_type, int>::value), "");
+    static_assert((std::is_same<std::set<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::set<int>::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::set<int>::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<std::set<int>::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<std::set<int>::reference, int&>::value), "");
+    static_assert((std::is_same<std::set<int>::const_reference, const int&>::value), "");
+    static_assert((std::is_same<std::set<int>::pointer, int*>::value), "");
+    static_assert((std::is_same<std::set<int>::const_pointer, const int*>::value), "");
+    static_assert((std::is_same<std::set<int>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::set<int>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/containers/associative/set/upper_bound.pass.cpp b/test/containers/associative/set/upper_bound.pass.cpp
new file mode 100644
index 0000000..398d8aa
--- /dev/null
+++ b/test/containers/associative/set/upper_bound.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+}
diff --git a/test/containers/associative/set/version.pass.cpp b/test/containers/associative/set/version.pass.cpp
new file mode 100644
index 0000000..6eac6e0
--- /dev/null
+++ b/test/containers/associative/set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+#include <set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/associative/tree_balance_after_insert.pass.cpp b/test/containers/associative/tree_balance_after_insert.pass.cpp
new file mode 100644
index 0000000..3ec1f19
--- /dev/null
+++ b/test/containers/associative/tree_balance_after_insert.pass.cpp
@@ -0,0 +1,1616 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __root->__is_black_ == true
+// template <class _NodePtr>
+// void
+// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+    bool __is_black_;
+
+    Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = &a;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &a);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = &a;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &d;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &a);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = &a;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &d;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == &a);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = &g;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = &h;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &b;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+    
+        h.__parent_ = &d;
+        h.__is_black_ = true;
+    
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &g);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &h);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &a;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = &h;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &b;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+    
+        h.__parent_ = &d;
+        h.__is_black_ = true;
+    
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &a);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &h);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &h;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = &a;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &d;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+    
+        h.__parent_ = &b;
+        h.__is_black_ = true;
+    
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &h);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &a);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &h;
+        b.__is_black_ = false;
+    
+        d.__parent_ = &c;
+        d.__left_ = &i;
+        d.__right_ = &a;
+        d.__is_black_ = false;
+    
+        a.__parent_ = &d;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+    
+        h.__parent_ = &b;
+        h.__is_black_ = true;
+    
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+    
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+    
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &h);
+        assert(b.__is_black_ == true);
+    
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &i);
+        assert(d.__right_ == &a);
+        assert(d.__is_black_ == true);
+    
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+}
+
+void
+test2()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &a;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+    
+        a.__parent_ = &c;
+        a.__left_ = 0;
+        a.__right_ = &b;
+        a.__is_black_ = false;
+    
+        b.__parent_ = &a;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &b);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+    
+        root.__left_ = &a;
+    
+        a.__parent_ = &root;
+        a.__left_ = 0;
+        a.__right_ = &c;
+        a.__is_black_ = true;
+    
+        c.__parent_ = &a;
+        c.__left_ = &b;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+    
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &b);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &a;
+        c.__right_ = &g;
+        c.__is_black_ = true;
+    
+        a.__parent_ = &c;
+        a.__left_ = &d;
+        a.__right_ = &b;
+        a.__is_black_ = false;
+    
+        b.__parent_ = &a;
+        b.__left_ = &e;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+    
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &b);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+    
+        root.__left_ = &a;
+    
+        a.__parent_ = &root;
+        a.__left_ = &d;
+        a.__right_ = &c;
+        a.__is_black_ = true;
+    
+        c.__parent_ = &a;
+        c.__left_ = &b;
+        c.__right_ = &g;
+        c.__is_black_ = false;
+    
+        b.__parent_ = &c;
+        b.__left_ = &e;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+    
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &b);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+}
+
+void
+test3()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+    
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+    
+        root.__left_ = &a;
+    
+        a.__parent_ = &root;
+        a.__left_ = 0;
+        a.__right_ = &b;
+        a.__is_black_ = true;
+    
+        b.__parent_ = &a;
+        b.__left_ = 0;
+        b.__right_ = &c;
+        b.__is_black_ = false;
+    
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+    
+        std::__tree_balance_after_insert(root.__left_, &c);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+    
+        root.__left_ = &c;
+    
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &g;
+        c.__is_black_ = true;
+    
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = &d;
+        a.__right_ = &e;
+        a.__is_black_ = false;
+    
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+    
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &a);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+    
+        root.__left_ = &a;
+    
+        a.__parent_ = &root;
+        a.__left_ = &d;
+        a.__right_ = &b;
+        a.__is_black_ = true;
+    
+        b.__parent_ = &a;
+        b.__left_ = &e;
+        b.__right_ = &c;
+        b.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = &f;
+        c.__right_ = &g;
+        c.__is_black_ = false;
+    
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+    
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &c;
+        f.__is_black_ = true;
+    
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+    
+        std::__tree_balance_after_insert(root.__left_, &c);
+    
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+    
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+}
+
+void
+test4()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &a;
+    a.__parent_ = &root;
+
+    std::__tree_balance_after_insert(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    a.__right_ = &b;
+    b.__parent_ = &a;
+
+    std::__tree_balance_after_insert(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == &b);
+    assert(a.__is_black_ == true);
+
+    assert(b.__parent_ == &a);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == false);
+
+    b.__right_ = &c;
+    c.__parent_ = &b;
+
+    std::__tree_balance_after_insert(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    c.__right_ = &d;
+    d.__parent_ = &c;
+
+    std::__tree_balance_after_insert(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    d.__right_ = &e;
+    e.__parent_ = &d;
+
+    std::__tree_balance_after_insert(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    e.__right_ = &f;
+    f.__parent_ = &e;
+
+    std::__tree_balance_after_insert(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == false);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    f.__right_ = &g;
+    g.__parent_ = &f;
+
+    std::__tree_balance_after_insert(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == false);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == false);
+
+    g.__right_ = &h;
+    h.__parent_ = &g;
+
+    std::__tree_balance_after_insert(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &b);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(b.__parent_ == &d);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+}
+
+void
+test5()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &h;
+    h.__parent_ = &root;
+
+    std::__tree_balance_after_insert(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    h.__left_ = &g;
+    g.__parent_ = &h;
+
+    std::__tree_balance_after_insert(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == &g);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    assert(g.__parent_ == &h);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == false);
+
+    g.__left_ = &f;
+    f.__parent_ = &g;
+
+    std::__tree_balance_after_insert(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    f.__left_ = &e;
+    e.__parent_ = &f;
+
+    std::__tree_balance_after_insert(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    e.__left_ = &d;
+    d.__parent_ = &e;
+
+    std::__tree_balance_after_insert(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    d.__left_ = &c;
+    c.__parent_ = &d;
+
+    std::__tree_balance_after_insert(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == false);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    c.__left_ = &b;
+    b.__parent_ = &c;
+
+    std::__tree_balance_after_insert(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == false);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    b.__left_ = &a;
+    a.__parent_ = &b;
+
+    std::__tree_balance_after_insert(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &g);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(g.__parent_ == &e);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == false);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+}
diff --git a/test/containers/associative/tree_left_rotate.pass.cpp b/test/containers/associative/tree_left_rotate.pass.cpp
new file mode 100644
index 0000000..492619e
--- /dev/null
+++ b/test/containers/associative/tree_left_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __x->__right_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_left_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+
+    Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+    Node root;
+    Node x;
+    Node y;
+    root.__left_ = &x;
+    x.__left_ = 0;
+    x.__right_ = &y;
+    x.__parent_ = &root;
+    y.__left_ = 0;
+    y.__right_ = 0;
+    y.__parent_ = &x;
+    std::__tree_left_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &x);
+    assert(y.__right_ == 0);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == 0);
+    assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+    Node root;
+    Node x;
+    Node y;
+    Node a;
+    Node b;
+    Node c;
+    root.__left_ = &x;
+    x.__left_ = &a;
+    x.__right_ = &y;
+    x.__parent_ = &root;
+    y.__left_ = &b;
+    y.__right_ = &c;
+    y.__parent_ = &x;
+    a.__parent_ = &x;
+    b.__parent_ = &y;
+    c.__parent_ = &y;
+    std::__tree_left_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &x);
+    assert(y.__right_ == &c);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == &a);
+    assert(x.__right_ == &b);
+    assert(a.__parent_ == &x);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(b.__parent_ == &x);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(c.__parent_ == &y);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/containers/associative/tree_remove.pass.cpp b/test/containers/associative/tree_remove.pass.cpp
new file mode 100644
index 0000000..03af737
--- /dev/null
+++ b/test/containers/associative/tree_remove.pass.cpp
@@ -0,0 +1,1648 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Returns __tree_next(__z)
+// template <class _NodePtr>
+// void
+// __tree_remove(_NodePtr __root, _NodePtr __z)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+    bool __is_black_;
+
+    Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+    {
+        // Left
+        // Case 1 -> Case 2 -> x is red turned to black
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node y;
+    
+        root.__left_ = &b;
+    
+        b.__parent_ = &root;
+        b.__left_ = &y;
+        b.__right_ = &d;
+        b.__is_black_ = true;
+    
+        y.__parent_ = &b;
+        y.__left_ = 0;
+        y.__right_ = 0;
+        y.__is_black_ = true;
+    
+        d.__parent_ = &b;
+        d.__left_ = &c;
+        d.__right_ = &e;
+        d.__is_black_ = false;
+    
+        c.__parent_ = &d;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+    
+        e.__parent_ = &d;
+        e.__left_ = 0;
+        e.__right_ = 0;
+        e.__is_black_ = true;
+    
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+    
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    
+        assert(d.__parent_ == &root);
+        assert(d.__left_ == &b);
+        assert(d.__right_ == &e);
+        assert(d.__is_black_ == true);
+    
+        assert(b.__parent_ == &d);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(e.__parent_ == &d);
+        assert(e.__left_ == 0);
+        assert(e.__right_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Right
+        // Case 1 -> Case 2 -> x is red turned to black
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node y;
+    
+        root.__left_ = &b;
+    
+        b.__parent_ = &root;
+        b.__right_ = &y;
+        b.__left_ = &d;
+        b.__is_black_ = true;
+    
+        y.__parent_ = &b;
+        y.__right_ = 0;
+        y.__left_ = 0;
+        y.__is_black_ = true;
+    
+        d.__parent_ = &b;
+        d.__right_ = &c;
+        d.__left_ = &e;
+        d.__is_black_ = false;
+    
+        c.__parent_ = &d;
+        c.__right_ = 0;
+        c.__left_ = 0;
+        c.__is_black_ = true;
+    
+        e.__parent_ = &d;
+        e.__right_ = 0;
+        e.__left_ = 0;
+        e.__is_black_ = true;
+    
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+    
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    
+        assert(d.__parent_ == &root);
+        assert(d.__right_ == &b);
+        assert(d.__left_ == &e);
+        assert(d.__is_black_ == true);
+    
+        assert(b.__parent_ == &d);
+        assert(b.__right_ == 0);
+        assert(b.__left_ == &c);
+        assert(b.__is_black_ == true);
+    
+        assert(c.__parent_ == &b);
+        assert(c.__right_ == 0);
+        assert(c.__left_ == 0);
+        assert(c.__is_black_ == false);
+    
+        assert(e.__parent_ == &d);
+        assert(e.__right_ == 0);
+        assert(e.__left_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Left
+        // Case 1 -> Case 3 -> Case 4
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node y;
+    
+        root.__left_ = &b;
+    
+        b.__parent_ = &root;
+        b.__left_ = &y;
+        b.__right_ = &d;
+        b.__is_black_ = true;
+    
+        y.__parent_ = &b;
+        y.__left_ = 0;
+        y.__right_ = 0;
+        y.__is_black_ = true;
+    
+        d.__parent_ = &b;
+        d.__left_ = &c;
+        d.__right_ = &e;
+        d.__is_black_ = false;
+    
+        c.__parent_ = &d;
+        c.__left_ = &f;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+    
+        e.__parent_ = &d;
+        e.__left_ = 0;
+        e.__right_ = 0;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &c;
+        f.__left_ = 0;
+        f.__right_ = 0;
+        f.__is_black_ = false;
+    
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+    
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    
+        assert(d.__parent_ == &root);
+        assert(d.__left_ == &f);
+        assert(d.__right_ == &e);
+        assert(d.__is_black_ == true);
+    
+        assert(f.__parent_ == &d);
+        assert(f.__left_ == &b);
+        assert(f.__right_ == &c);
+        assert(f.__is_black_ == false);
+    
+        assert(b.__parent_ == &f);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+    
+        assert(c.__parent_ == &f);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+    
+        assert(e.__parent_ == &d);
+        assert(e.__left_ == 0);
+        assert(e.__right_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Right
+        // Case 1 -> Case 3 -> Case 4
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node y;
+    
+        root.__left_ = &b;
+    
+        b.__parent_ = &root;
+        b.__right_ = &y;
+        b.__left_ = &d;
+        b.__is_black_ = true;
+    
+        y.__parent_ = &b;
+        y.__right_ = 0;
+        y.__left_ = 0;
+        y.__is_black_ = true;
+    
+        d.__parent_ = &b;
+        d.__right_ = &c;
+        d.__left_ = &e;
+        d.__is_black_ = false;
+    
+        c.__parent_ = &d;
+        c.__right_ = &f;
+        c.__left_ = 0;
+        c.__is_black_ = true;
+    
+        e.__parent_ = &d;
+        e.__right_ = 0;
+        e.__left_ = 0;
+        e.__is_black_ = true;
+    
+        f.__parent_ = &c;
+        f.__right_ = 0;
+        f.__left_ = 0;
+        f.__is_black_ = false;
+    
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+    
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    
+        assert(d.__parent_ == &root);
+        assert(d.__right_ == &f);
+        assert(d.__left_ == &e);
+        assert(d.__is_black_ == true);
+    
+        assert(f.__parent_ == &d);
+        assert(f.__right_ == &b);
+        assert(f.__left_ == &c);
+        assert(f.__is_black_ == false);
+    
+        assert(b.__parent_ == &f);
+        assert(b.__right_ == 0);
+        assert(b.__left_ == 0);
+        assert(b.__is_black_ == true);
+    
+        assert(c.__parent_ == &f);
+        assert(c.__right_ == 0);
+        assert(c.__left_ == 0);
+        assert(c.__is_black_ == true);
+    
+        assert(e.__parent_ == &d);
+        assert(e.__right_ == 0);
+        assert(e.__left_ == 0);
+        assert(e.__is_black_ == true);
+    }
+}
+
+void
+test2()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+}
+
+void
+test3()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &e;
+
+    e.__parent_ = &root;
+    e.__left_ = &c;
+    e.__right_ = &g;
+    e.__is_black_ = true;
+
+    c.__parent_ = &e;
+    c.__left_ = &b;
+    c.__right_ = &d;
+    c.__is_black_ = false;
+
+    g.__parent_ = &e;
+    g.__left_ = &f;
+    g.__right_ = &h;
+    g.__is_black_ = false;
+
+    b.__parent_ = &c;
+    b.__left_ = &a;
+    b.__right_ = 0;
+    b.__is_black_ = true;
+
+    d.__parent_ = &c;
+    d.__left_ = 0;
+    d.__right_ = 0;
+    d.__is_black_ = true;
+
+    f.__parent_ = &g;
+    f.__left_ = 0;
+    f.__right_ = 0;
+    f.__is_black_ = true;
+
+    h.__parent_ = &g;
+    h.__left_ = 0;
+    h.__right_ = 0;
+    h.__is_black_ = true;
+
+    a.__parent_ = &b;
+    a.__left_ = 0;
+    a.__right_ = 0;
+    a.__is_black_ = false;
+
+    assert(std::__tree_invariant(root.__left_));
+
+    std::__tree_remove(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &g);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(g.__parent_ == &e);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &c);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(c.__parent_ == &root);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &e);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(e.__parent_ == &c);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &c);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(c.__parent_ == &root);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == 0);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+}
+
+void
+test4()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &d;
+
+    d.__parent_ = &root;
+    d.__left_ = &b;
+    d.__right_ = &f;
+    d.__is_black_ = true;
+
+    b.__parent_ = &d;
+    b.__left_ = &a;
+    b.__right_ = &c;
+    b.__is_black_ = false;
+
+    f.__parent_ = &d;
+    f.__left_ = &e;
+    f.__right_ = &g;
+    f.__is_black_ = false;
+
+    a.__parent_ = &b;
+    a.__left_ = 0;
+    a.__right_ = 0;
+    a.__is_black_ = true;
+
+    c.__parent_ = &b;
+    c.__left_ = 0;
+    c.__right_ = 0;
+    c.__is_black_ = true;
+
+    e.__parent_ = &f;
+    e.__left_ = 0;
+    e.__right_ = 0;
+    e.__is_black_ = true;
+
+    g.__parent_ = &f;
+    g.__left_ = 0;
+    g.__right_ = &h;
+    g.__is_black_ = true;
+
+    h.__parent_ = &g;
+    h.__left_ = 0;
+    h.__right_ = 0;
+    h.__is_black_ = false;
+
+    assert(std::__tree_invariant(root.__left_));
+
+    std::__tree_remove(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &b);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(b.__parent_ == &d);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &f);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(f.__parent_ == &root);
+    assert(f.__left_ == &d);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(d.__parent_ == &f);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &f);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(f.__parent_ == &root);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == 0);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+}
diff --git a/test/containers/associative/tree_right_rotate.pass.cpp b/test/containers/associative/tree_right_rotate.pass.cpp
new file mode 100644
index 0000000..41721cf
--- /dev/null
+++ b/test/containers/associative/tree_right_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __x->__left_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_right_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+
+    Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+    Node root;
+    Node x;
+    Node y;
+    root.__left_ = &x;
+    x.__left_ = &y;
+    x.__right_ = 0;
+    x.__parent_ = &root;
+    y.__left_ = 0;
+    y.__right_ = 0;
+    y.__parent_ = &x;
+    std::__tree_right_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == 0);
+    assert(y.__right_ == &x);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == 0);
+    assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+    Node root;
+    Node x;
+    Node y;
+    Node a;
+    Node b;
+    Node c;
+    root.__left_ = &x;
+    x.__left_ = &y;
+    x.__right_ = &c;
+    x.__parent_ = &root;
+    y.__left_ = &a;
+    y.__right_ = &b;
+    y.__parent_ = &x;
+    a.__parent_ = &y;
+    b.__parent_ = &y;
+    c.__parent_ = &x;
+    std::__tree_right_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &a);
+    assert(y.__right_ == &x);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == &b);
+    assert(x.__right_ == &c);
+    assert(a.__parent_ == &y);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(b.__parent_ == &x);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(c.__parent_ == &x);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp b/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp b/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp b/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp b/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/nothing_to_do.pass.cpp b/test/containers/container.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp b/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp b/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp b/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/containers.general/nothing_to_do.pass.cpp b/test/containers/containers.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/containers.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/iterators.h b/test/containers/iterators.h
new file mode 100644
index 0000000..85332ac
--- /dev/null
+++ b/test/containers/iterators.h
@@ -0,0 +1,251 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+#endif
diff --git a/test/containers/nothing_to_do.pass.cpp b/test/containers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/sequences/array/array.cons/default.pass.cpp b/test/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 0000000..c8fc3aa
--- /dev/null
+++ b/test/containers/sequences/array/array.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// array();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c;
+        assert(c.size() == 3);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c;
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.cons/initializer_list.pass.cpp b/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..f554283
--- /dev/null
+++ b/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// Construct with initizializer list
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        assert(c.size() == 3);
+        assert(c[0] == 1);
+        assert(c[1] == 2);
+        assert(c[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.data/data.pass.cpp b/test/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 0000000..147fe9e
--- /dev/null
+++ b/test/containers/sequences/array/array.data/data.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// T *data();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        T* p = c.data();
+        assert(p[0] == 1);
+        assert(p[1] == 2);
+        assert(p[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        T* p = c.data();
+    }
+}
diff --git a/test/containers/sequences/array/array.data/data_const.pass.cpp b/test/containers/sequences/array/array.data/data_const.pass.cpp
new file mode 100644
index 0000000..63d2fcb
--- /dev/null
+++ b/test/containers/sequences/array/array.data/data_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// const T* data() const;
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        const T* p = c.data();
+        assert(p[0] == 1);
+        assert(p[1] == 2);
+        assert(p[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        const C c = {};
+        const T* p = c.data();
+    }
+}
diff --git a/test/containers/sequences/array/array.fill/fill.pass.cpp b/test/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 0000000..d8c3918
--- /dev/null
+++ b/test/containers/sequences/array/array.fill/fill.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void fill(const T& u);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        c.fill(5.5);
+        assert(c.size() == 3);
+        assert(c[0] == 5.5);
+        assert(c[1] == 5.5);
+        assert(c[2] == 5.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        c.fill(5.5);
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.size/size.pass.cpp b/test/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 0000000..3f9d7b9
--- /dev/null
+++ b/test/containers/sequences/array/array.size/size.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        assert(c.size() == 3);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.special/swap.pass.cpp b/test/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 0000000..4b0a47f
--- /dev/null
+++ b/test/containers/sequences/array/array.special/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c1 = {1, 2, 3.5};
+        C c2 = {4, 5, 6.5};
+        swap(c1, c2);
+        assert(c1.size() == 3);
+        assert(c1[0] == 4);
+        assert(c1[1] == 5);
+        assert(c1[2] == 6.5);
+        assert(c2.size() == 3);
+        assert(c2[0] == 1);
+        assert(c2[1] == 2);
+        assert(c2[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c1 = {};
+        C c2 = {};
+        swap(c1, c2);
+        assert(c1.size() == 0);
+        assert(c2.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.swap/swap.pass.cpp b/test/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 0000000..4470775
--- /dev/null
+++ b/test/containers/sequences/array/array.swap/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void swap(array& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c1 = {1, 2, 3.5};
+        C c2 = {4, 5, 6.5};
+        c1.swap(c2);
+        assert(c1.size() == 3);
+        assert(c1[0] == 4);
+        assert(c1[1] == 5);
+        assert(c1[2] == 6.5);
+        assert(c2.size() == 3);
+        assert(c2[0] == 1);
+        assert(c2[1] == 2);
+        assert(c2[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c1 = {};
+        C c2 = {};
+        c1.swap(c2);
+        assert(c1.size() == 0);
+        assert(c2.size() == 0);
+    }
+}
diff --git a/test/containers/sequences/array/array.tuple/get.pass.cpp b/test/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 0000000..8fc28c7
--- /dev/null
+++ b/test/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        std::get<1>(c) = 5.5;
+        assert(c[0] == 1);
+        assert(c[1] == 5.5);
+        assert(c[2] == 3.5);
+    }
+}
diff --git a/test/containers/sequences/array/array.tuple/get_const.pass.cpp b/test/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 0000000..6380bc8
--- /dev/null
+++ b/test/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        assert(std::get<0>(c) == 1);
+        assert(std::get<1>(c) == 2);
+        assert(std::get<2>(c) == 3.5);
+    }
+}
diff --git a/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 0000000..fd58ed7
--- /dev/null
+++ b/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+#include <array>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+    }
+    {
+        typedef int T;
+        typedef std::array<T, 3> C;
+        static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+    }
+}
diff --git a/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 0000000..403fbd3
--- /dev/null
+++ b/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_size<array<T, N> >::value
+
+#include <array>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        static_assert((std::tuple_size<C>::value == 3), "");
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        static_assert((std::tuple_size<C>::value == 0), "");
+    }
+}
diff --git a/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..9dc64a0
--- /dev/null
+++ b/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/test/containers/sequences/array/begin.pass.cpp b/test/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 0000000..98f456f
--- /dev/null
+++ b/test/containers/sequences/array/begin.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator begin();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        C::iterator i = c.begin();
+        assert(*i == 1);
+        assert(&*i == c.data());
+        *i = 5.5;
+        assert(c[0] == 5.5);
+    }
+    {
+    }
+}
diff --git a/test/containers/sequences/array/types.pass.cpp b/test/containers/sequences/array/types.pass.cpp
new file mode 100644
index 0000000..f1f200f
--- /dev/null
+++ b/test/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N > 
+// struct array
+// { 
+//     // types: 
+//     typedef T& reference; 
+//     typedef const T& const_reference; 
+//     typedef implementation defined iterator; 
+//     typedef implementation defined const_iterator; 
+//     typedef T value_type; 
+//     typedef T* pointer;
+//     typedef size_t size_type; 
+//     typedef ptrdiff_t difference_type; 
+//     typedef T value_type; 
+//     typedef std::reverse_iterator<iterator> reverse_iterator; 
+//     typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 10> C;
+        static_assert((std::is_same<C::reference, T&>::value), "");
+        static_assert((std::is_same<C::const_reference, const T&>::value), "");
+        static_assert((std::is_same<C::iterator, T*>::value), "");
+        static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+        static_assert((std::is_same<C::pointer, T*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+        static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+    }
+    {
+        typedef int* T;
+        typedef std::array<T, 0> C;
+        static_assert((std::is_same<C::reference, T&>::value), "");
+        static_assert((std::is_same<C::const_reference, const T&>::value), "");
+        static_assert((std::is_same<C::iterator, T*>::value), "");
+        static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+        static_assert((std::is_same<C::pointer, T*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+        static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+    }
+}
diff --git a/test/containers/sequences/array/version.pass.cpp b/test/containers/sequences/array/version.pass.cpp
new file mode 100644
index 0000000..fed0e11
--- /dev/null
+++ b/test/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/container.adaptors/nothing_to_do.pass.cpp b/test/containers/sequences/container.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..5c91782
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     explicit priority_queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> q((test_allocator<int>(3)));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.c.size() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
new file mode 100644
index 0000000..399018a
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> q(std::less<int>(), test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.c.size() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
new file mode 100644
index 0000000..467b3fa
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, const container_type& c,
+//                    const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    typedef std::vector<int, test_allocator<int> > C;
+    C v = make<C>(5);
+    test<int> q(std::less<int>(), v, test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.size() == 5);
+    assert(q.top() == 4);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
new file mode 100644
index 0000000..a4fb5b3
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, container_type&& c,
+//                    const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    typedef std::vector<int, test_allocator<int> > C;
+    test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.size() == 5);
+    assert(q.top() == 4);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 0000000..f526cb4
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const priority_queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+#include "../../../../test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+         const test_allocator<int>& a) : base(comp, c, a) {}
+    test(const test& q, const test_allocator<int>& a) : base(q, a) {}
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> qo(std::less<int>(),
+                      make<std::vector<int, test_allocator<int> > >(5),
+                      test_allocator<int>(2));
+    test<int> q(qo, test_allocator<int>(6));
+    assert(q.size() == 5);
+    assert(q.c.get_allocator() == test_allocator<int>(6));
+    assert(q.top() == int(4));
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
new file mode 100644
index 0000000..40361a4
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(priority_queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#include "../../../../test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test<MoveOnly> qo(std::less<MoveOnly>(),
+                      make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5),
+                      test_allocator<MoveOnly>(2));
+    test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6));
+    assert(q.size() == 5);
+    assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
+    assert(q.top() == MoveOnly(4));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..d696540
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q;
+    q = qo;
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..70d75c6
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    std::priority_queue<MoveOnly> q;
+    q = std::move(qo);
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
new file mode 100644
index 0000000..ea3a5cc
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../stack_allocator.h"
+
+int main()
+{
+    std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
new file mode 100644
index 0000000..b8a178c
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
new file mode 100644
index 0000000..9fb559f
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..ce1a46a
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..547d0f1
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../stack_allocator.h"
+
+int main()
+{
+    std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
new file mode 100644
index 0000000..4ba4aa6
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::priority_queue<int> q(a, an);
+    assert(q.size() == an - a);
+    assert(q.top() == 8);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..87c29ab
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last, const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::priority_queue<int, std::vector<int>, std::greater<int> >
+        q(a, an, std::greater<int>());
+    assert(q.size() == an - a);
+    assert(q.top() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
new file mode 100644
index 0000000..4d56b77
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last,
+//                  const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    const int n = sizeof(a)/sizeof(a[0]);
+    std::vector<int> v(a, a+n/2);
+    std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
+    assert(q.size() == n);
+    assert(q.top() == 8);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
new file mode 100644
index 0000000..c13c97f
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last,
+//                  const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    const int n = sizeof(a)/sizeof(a[0]);
+    std::priority_queue<MoveOnly> q(a+n/2, a+n,
+                                    std::less<MoveOnly>(),
+                                    std::vector<MoveOnly>(a, a+n/2));
+    assert(q.size() == n);
+    assert(q.top() == MoveOnly(8));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..e762972
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    std::priority_queue<MoveOnly> q = std::move(qo);
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
new file mode 100644
index 0000000..8651e1e
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::priority_queue<Emplaceable> q;
+    q.emplace(1, 2.5);
+    assert(q.top() == Emplaceable(1, 2.5));
+    q.emplace(3, 4.5);
+    assert(q.top() == Emplaceable(3, 4.5));
+    q.emplace(2, 3.5);
+    assert(q.top() == Emplaceable(3, 4.5));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
new file mode 100644
index 0000000..53397ce
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// bool empty() const;
+
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
new file mode 100644
index 0000000..858224d
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+    q.pop();
+    assert(q.top() == 2);
+    q.pop();
+    assert(q.top() == 1);
+    q.pop();
+    assert(q.empty());
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
new file mode 100644
index 0000000..ba70691
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
new file mode 100644
index 0000000..0db166a
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/push_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::priority_queue<MoveOnly> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/size.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
new file mode 100644
index 0000000..a75523e
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
new file mode 100644
index 0000000..729604b
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void swap(priority_queue& q);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q1;
+    std::priority_queue<int> q2;
+    q1.push(1);
+    q1.push(3);
+    q1.push(2);
+    q1.swap(q2);
+    assert(q1.empty());
+    assert(q2.size() == 3);
+    assert(q2.top() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/top.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
new file mode 100644
index 0000000..014bbfa
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// const_reference top() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
new file mode 100644
index 0000000..6987f73
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/priqueue.special/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class T, class Container, class Compare>
+//   void swap(priority_queue<T, Container, Compare>& x,
+//             priority_queue<T, Container, Compare>& y);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q1;
+    std::priority_queue<int> q2;
+    q1.push(1);
+    q1.push(3);
+    q1.push(2);
+    swap(q1, q2);
+    assert(q1.empty());
+    assert(q2.size() == 3);
+    assert(q2.top() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/priority.queue/types.pass.cpp b/test/containers/sequences/container.adaptors/priority.queue/types.pass.cpp
new file mode 100644
index 0000000..13051b0
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/priority.queue/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = vector<T>,
+//           class Compare = less<typename Container::value_type>>
+// class priority_queue
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+// 
+// protected:
+//     container_type c;
+//     Compare comp;
+
+#include <queue>
+#include <cassert>
+#include <type_traits>
+
+struct test
+    : private std::priority_queue<int>
+{
+    test()
+    {
+        c.push_back(1);
+        assert(comp(1, 2));
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..07bc9cc
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   explicit queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+struct test
+    : private std::queue<int, std::deque<int, test_allocator<int> > >
+{
+    typedef std::queue<int, std::deque<int, test_allocator<int> > > base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    test q(test_allocator<int>(3));
+    assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 0000000..ae93fd3
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+    : public std::queue<int, C>
+{
+    typedef std::queue<int, C> base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    C d = make<C>(5);
+    test q(d, test_allocator<int>(4));
+    assert(q.get_allocator() == test_allocator<int>(4));
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.front() == d[i]);
+        q.pop();
+    }
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
new file mode 100644
index 0000000..a3b1192
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<int>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(const test& q, const allocator_type& a) : base(q, a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+    test<int> q(make<C>(5), test_allocator<int>(4));
+    test<int> q2(q, test_allocator<int>(5));
+    assert(q2.get_allocator() == test_allocator<int>(5));
+    assert(q2.size() == 5);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 0000000..21b73c3
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+    assert(q.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 0000000..1789c9f
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+    assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+    assert(q2.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
new file mode 100644
index 0000000..66d813d
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_container.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::deque<int> d = make<std::deque<int> >(5);
+    std::queue<int> q(d);
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.front() == d[i]);
+        q.pop();
+    }
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..d96d013
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(const queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q(make<std::deque<int> >(5));
+    std::queue<int> q2 = q;
+    assert(q2 == q);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..188a7cd
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../stack_allocator.h"
+
+int main()
+{
+    std::queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.front() == 1);
+    assert(q.back() == 2);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..d9a8e0b
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::queue<MoveOnly> q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 0000000..123b671
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    assert(q.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
new file mode 100644
index 0000000..0d3cb3e
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(const queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q(make<std::deque<int> >(5));
+    std::queue<int> q2;
+    q2 = q;
+    assert(q2 == q);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/assign_move.pass.cpp
new file mode 100644
index 0000000..bae8db1
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::queue<MoveOnly> q2;
+    q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/back.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/back.pass.cpp
new file mode 100644
index 0000000..55e28bb
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference back();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.back();
+    assert(ir == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/back_const.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/back_const.pass.cpp
new file mode 100644
index 0000000..fc39b6b
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/back_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference back() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::queue<int>& cqr = q;
+    const int& cir = cqr.back();
+    assert(cir == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/emplace.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/emplace.pass.cpp
new file mode 100644
index 0000000..1158875
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/emplace.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::queue<Emplaceable> q;
+    q.emplace(1, 2.5);
+    q.emplace(2, 3.5);
+    q.emplace(3, 4.5);
+    assert(q.size() == 3);
+    assert(q.front() == Emplaceable(1, 2.5));
+    assert(q.back() == Emplaceable(3, 4.5));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/empty.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/empty.pass.cpp
new file mode 100644
index 0000000..a59ef7c
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/front.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/front.pass.cpp
new file mode 100644
index 0000000..0f57001
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference front();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.front();
+    assert(ir == 1);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/front_const.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/front_const.pass.cpp
new file mode 100644
index 0000000..b3e1b56
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/front_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference front() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::queue<int>& cqr = q;
+    const int& cir = cqr.front();
+    assert(cir == 1);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/pop.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/pop.pass.cpp
new file mode 100644
index 0000000..df32f89
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/pop.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.front() == 1);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 2);
+    assert(q.front() == 2);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 1);
+    assert(q.front() == 3);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/push.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/push.pass.cpp
new file mode 100644
index 0000000..4a0b650
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/push.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    q.push(1);
+    assert(q.size() == 1);
+    assert(q.front() == 1);
+    assert(q.back() == 1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.front() == 1);
+    assert(q.back() == 2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.front() == 1);
+    assert(q.back() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/push_rv.pass.cpp
new file mode 100644
index 0000000..356410e
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/push_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::queue<MoveOnly> q;
+    q.push(MoveOnly(1));
+    assert(q.size() == 1);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(1));
+    q.push(MoveOnly(2));
+    assert(q.size() == 2);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(2));
+    q.push(MoveOnly(3));
+    assert(q.size() == 3);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(3));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/size.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/size.pass.cpp
new file mode 100644
index 0000000..9d58445
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/swap.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/swap.pass.cpp
new file mode 100644
index 0000000..c220921
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    q1.swap(q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.defn/types.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.defn/types.pass.cpp
new file mode 100644
index 0000000..8e3aaec
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.defn/types.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = deque<T>>
+// class queue
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+// 
+// protected:
+//     container_type c;
+// ...
+// };
+
+#include <queue>
+#include <type_traits>
+
+struct test
+    : private std::queue<int>
+{
+    test()
+    {
+        c.push_back(1);
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), "");
+    static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.ops/eq.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.ops/eq.pass.cpp
new file mode 100644
index 0000000..32cdc5e
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    assert(q1 == q1_save);
+    assert(q1 != q2);
+    assert(q2 == q2_save);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.ops/lt.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.ops/lt.pass.cpp
new file mode 100644
index 0000000..ac2c0d4
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.ops/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    assert(q1 < q2);
+    assert(q2 > q1);
+    assert(q1 <= q2);
+    assert(q2 >= q1);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/queue.special/swap.pass.cpp b/test/containers/sequences/container.adaptors/queue/queue.special/swap.pass.cpp
new file mode 100644
index 0000000..cdbb84a
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/queue.special/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   void swap(queue<T, Container>& x, queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    swap(q1, q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/test/containers/sequences/container.adaptors/queue/version.pass.cpp b/test/containers/sequences/container.adaptors/queue/version.pass.cpp
new file mode 100644
index 0000000..7515597
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/queue/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+#include <queue>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..bcd9c42
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   explicit stack(const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+struct test
+    : private std::stack<int, std::deque<int, test_allocator<int> > >
+{
+    typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    test q(test_allocator<int>(3));
+    assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 0000000..296ae64
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+    : public std::stack<int, C>
+{
+    typedef std::stack<int, C> base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifdef _LIBCPP_MOVE
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    C d = make<C>(5);
+    test q(d, test_allocator<int>(4));
+    assert(q.get_allocator() == test_allocator<int>(4));
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.top() == d[d.size() - i - 1]);
+        q.pop();
+    }
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 0000000..6bd16ae
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const stack& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(int(i));
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<int>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(const test& q, const allocator_type& a) : base(q, a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+    test<int> q(make<C>(5), test_allocator<int>(4));
+    test<int> q2(q, test_allocator<int>(5));
+    assert(q2.get_allocator() == test_allocator<int>(5));
+    assert(q2.size() == 5);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 0000000..711b71b
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+    assert(q.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 0000000..418bc97
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(stack&& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../test_allocator.h"
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+    assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+    assert(q2.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
new file mode 100644
index 0000000..5fa68ae
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_container.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(const container_type& c);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::deque<int> d = make<std::deque<int> >(5);
+    std::stack<int> q(d);
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.top() == d[d.size() - i - 1]);
+        q.pop();
+    }
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..06f5d50
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(const stack&) = default;
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q(make<std::deque<int> >(5));
+    std::stack<int> q2 = q;
+    assert(q2 == q);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..de12fb0
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack();
+
+#include <stack>
+#include <vector>
+#include <cassert>
+
+#include "../../../../stack_allocator.h"
+
+int main()
+{
+    std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..55b4c7a
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::stack<MoveOnly> q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 0000000..43051b5
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(container_type&& c);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    assert(q.size() == 5);
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/assign_copy.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
new file mode 100644
index 0000000..00ad5c0
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(const stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q(make<std::deque<int> >(5));
+    std::stack<int> q2;
+    q2 = q;
+    assert(q2 == q);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/assign_move.pass.cpp
new file mode 100644
index 0000000..6025e7b
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::stack<MoveOnly> q2;
+    q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/emplace.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/emplace.pass.cpp
new file mode 100644
index 0000000..1a5c107
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/emplace.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::stack<Emplaceable> q;
+    q.emplace(1, 2.5);
+    q.emplace(2, 3.5);
+    q.emplace(3, 4.5);
+    assert(q.size() == 3);
+    assert(q.top() == Emplaceable(3, 4.5));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/empty.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/empty.pass.cpp
new file mode 100644
index 0000000..1180204
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// bool empty() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/pop.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/pop.pass.cpp
new file mode 100644
index 0000000..cf62cd4
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void pop();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.top() == 3);
+    q.pop();
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+    q.pop();
+    assert(q.size() == 1);
+    assert(q.top() == 1);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/push.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/push.pass.cpp
new file mode 100644
index 0000000..17fc58d
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/push.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(const value_type& v);
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    q.push(1);
+    assert(q.size() == 1);
+    assert(q.top() == 1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.top() == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/push_rv.pass.cpp
new file mode 100644
index 0000000..5e9d554
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/push_rv.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(value_type&& v);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::stack<MoveOnly> q;
+    q.push(MoveOnly(1));
+    assert(q.size() == 1);
+    assert(q.top() == MoveOnly(1));
+    q.push(MoveOnly(2));
+    assert(q.size() == 2);
+    assert(q.top() == MoveOnly(2));
+    q.push(MoveOnly(3));
+    assert(q.size() == 3);
+    assert(q.top() == MoveOnly(3));
+#endif
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/size.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/size.pass.cpp
new file mode 100644
index 0000000..06d84d6
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// size_type size() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/swap.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/swap.pass.cpp
new file mode 100644
index 0000000..f3427b6
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    q1.swap(q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/top.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/top.pass.cpp
new file mode 100644
index 0000000..4c71dc1
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/top.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// reference top();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.top();
+    assert(ir == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/top_const.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/top_const.pass.cpp
new file mode 100644
index 0000000..7afceb0
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/top_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// const_reference top() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::stack<int>& cqr = q;
+    const int& cir = cqr.top();
+    assert(cir == 3);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.defn/types.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.defn/types.pass.cpp
new file mode 100644
index 0000000..7c12831
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.defn/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container = deque<T>>
+// class stack
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+// 
+// protected:
+//     container_type c;
+// ...
+// };
+
+#include <stack>
+#include <vector>
+#include <type_traits>
+
+struct test
+    : private std::stack<int>
+{
+    test()
+    {
+        c.push_back(1);
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
+    static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.ops/eq.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.ops/eq.pass.cpp
new file mode 100644
index 0000000..ceb5510
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    assert(q1 == q1_save);
+    assert(q1 != q2);
+    assert(q2 == q2_save);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.ops/lt.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.ops/lt.pass.cpp
new file mode 100644
index 0000000..a1dd3d2
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.ops/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
+// 
+// template <class T, class Container>
+//   bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    assert(q1 < q2);
+    assert(q2 > q1);
+    assert(q1 <= q2);
+    assert(q2 >= q1);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/stack.special/swap.pass.cpp b/test/containers/sequences/container.adaptors/stack/stack.special/swap.pass.cpp
new file mode 100644
index 0000000..f1913cd
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/stack.special/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   void swap(stack<T, Container>& x, stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    swap(q1, q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/test/containers/sequences/container.adaptors/stack/version.pass.cpp b/test/containers/sequences/container.adaptors/stack/version.pass.cpp
new file mode 100644
index 0000000..517d112
--- /dev/null
+++ b/test/containers/sequences/container.adaptors/stack/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+#include <stack>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/deque/deque.capacity/access.pass.cpp b/test/containers/sequences/deque/deque.capacity/access.pass.cpp
new file mode 100644
index 0000000..a0f140b
--- /dev/null
+++ b/test/containers/sequences/deque/deque.capacity/access.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+//       reference operator[](size_type __i);
+// const_reference operator[](size_type __i) const;
+// 
+//       reference at(size_type __i);
+// const_reference at(size_type __i) const;
+// 
+//       reference front();
+// const_reference front() const;
+// 
+//       reference back();
+// const_reference back() const;
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+int main()
+{
+    {
+        std::deque<int> c = make(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+    {
+        const std::deque<int> c = make(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+}
diff --git a/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..138230a
--- /dev/null
+++ b/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n);
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1, int size)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    c1.resize(size);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    CI i = c1.begin();
+    for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+        assert(*i == j);
+    for (int j = c1_osize; j < c1.size(); ++j, ++i)
+        assert(*i == 0);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    test(c1, M);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+}
diff --git a/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..a1dcb50
--- /dev/null
+++ b/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1, int size, int x)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    c1.resize(size, x);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    CI i = c1.begin();
+    for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+        assert(*i == j);
+    for (int j = c1_osize; j < c1.size(); ++j, ++i)
+        assert(*i == x);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    test(c1, M, -10);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+}
diff --git a/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..11bb34a
--- /dev/null
+++ b/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void shrink_to_fit();
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1)
+{
+    std::deque<int> s = c1;
+    c1.shrink_to_fit();
+    assert(c1 == s);
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    test(c1);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.cons/alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/alloc.pass.cpp
new file mode 100644
index 0000000..0a95f8a
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/alloc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+#include "../../../NotConstructible.h"
+
+template <class T, class Allocator>
+void
+test(const Allocator& a)
+{
+    std::deque<T, Allocator> d(a);
+    assert(d.size() == 0);
+    assert(d.get_allocator() == a);
+}
+
+int main()
+{
+    test<int>(std::allocator<int>());
+    test<NotConstructible>(test_allocator<NotConstructible>(3));
+}
diff --git a/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..84b8c36
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
new file mode 100644
index 0000000..a915bfe
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   void assign(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1, const std::deque<int>& c2)
+{
+    std::size_t c1_osize = c1.size();
+    c1.assign(c2.begin(), c2.end());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(c1 == c2);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    C c2 = make(M);
+    test(c1, c2);
+}
+
+void
+testI(std::deque<int>& c1, const std::deque<int>& c2)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    typedef input_iterator<CI> ICI;
+    std::size_t c1_osize = c1.size();
+    c1.assign(ICI(c2.begin()), ICI(c2.end()));
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(c1 == c2);
+}
+
+void
+testNI(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    C c2 = make(M);
+    testI(c1, c2);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+    testNI(1500, 2000, 1000);
+}
diff --git a/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
new file mode 100644
index 0000000..963366b
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1, int size, int v)
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    c1.assign(size, v);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    for (CI i = c1.begin(); i != c1.end(); ++i)
+        assert(*i == v);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    C c1 = make(N, start);
+    test(c1, M, -10);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+}
diff --git a/test/containers/sequences/deque/deque.cons/copy.pass.cpp b/test/containers/sequences/deque/deque.cons/copy.pass.cpp
new file mode 100644
index 0000000..00ee364
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/copy.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque&);
+
+#include <deque>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    C c(x);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int>(ab, an));
+    }
+    {
+        std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+        std::deque<int, test_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+        std::deque<int, other_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<int>(-2));
+    }
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..7b2dc60
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    C c(x, a);
+    assert(c == x);
+    assert(c.get_allocator() == a);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
+                                                           test_allocator<int>(4));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
+                                                            other_allocator<int>(4));
+    }
+}
diff --git a/test/containers/sequences/deque/deque.cons/default.pass.cpp b/test/containers/sequences/deque/deque.cons/default.pass.cpp
new file mode 100644
index 0000000..cf6074b
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../NotConstructible.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    std::deque<T, Allocator> d;
+    assert(d.size() == 0);
+}
+
+int main()
+{
+    test<int, std::allocator<int> >();
+    test<NotConstructible, stack_allocator<NotConstructible, 1> >();
+}
diff --git a/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..4718bf8
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..ec865c5
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <deque>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..ef7489d
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator> deque(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../iterators.h"
+
+template <class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::allocator<T> Allocator;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+template <class Allocator, class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+int main()
+{
+    int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+    int* an = ab + sizeof(ab)/sizeof(ab[0]);
+    test(input_iterator<const int*>(ab), input_iterator<const int*>(an));
+    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an));
+    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
+    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
+    test<stack_allocator<int, 4096> >(ab, an);
+}
diff --git a/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..c05e00d
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/iter_iter_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   deque(InputIterator f, InputIterator l, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_allocator.h"
+
+template <class InputIterator, class Allocator>
+void
+test(InputIterator f, InputIterator l, const Allocator& a)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l, a);
+    assert(d.get_allocator() == a);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+int main()
+{
+    int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+    int* an = ab + sizeof(ab)/sizeof(ab[0]);
+    test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
+    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
+    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
+    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
+}
diff --git a/test/containers/sequences/deque/deque.cons/move.pass.cpp b/test/containers/sequences/deque/deque.cons/move.pass.cpp
new file mode 100644
index 0000000..9d00b0c
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(2));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == c1.get_allocator());
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(2));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == c1.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..aedaf34
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/move_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(3));
+        assert(c1.size() != 0);
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(1));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(1));
+        assert(c1.size() == 0);
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(3));
+        assert(c1.size() != 0);
+    }
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..e368cc5
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(5));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == A(5));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(6));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() != 0);
+        assert(c3.get_allocator() == A(6));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(6));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == A(5));
+    }
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp
new file mode 100644
index 0000000..48f4f76
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/op_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(const deque& c);
+
+#include <deque>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    C c;
+    c = x;
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int>(ab, an));
+    }
+    {
+        std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+}
diff --git a/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..dd37698
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.cons/size.pass.cpp b/test/containers/sequences/deque/deque.cons/size.pass.cpp
new file mode 100644
index 0000000..6d38ab6
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/size.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../DefaultOnly.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    assert(DefaultOnly::count == 0);
+    {
+    C d(n);
+    assert(DefaultOnly::count == n);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+#ifdef _LIBCPP_MOVE
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == T());
+#endif
+    }
+    assert(DefaultOnly::count == 0);
+}
+
+int main()
+{
+    test<DefaultOnly, std::allocator<DefaultOnly> >(0);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(10);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
+    test<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+}
diff --git a/test/containers/sequences/deque/deque.cons/size_value.pass.cpp b/test/containers/sequences/deque/deque.cons/size_value.pass.cpp
new file mode 100644
index 0000000..a8f9f47
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/size_value.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(n, x);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<int, std::allocator<int> >(0, 5);
+    test<int, std::allocator<int> >(1, 10);
+    test<int, std::allocator<int> >(10, 11);
+    test<int, std::allocator<int> >(1023, -11);
+    test<int, std::allocator<int> >(1024, 25);
+    test<int, std::allocator<int> >(1025, 0);
+    test<int, std::allocator<int> >(2047, 110);
+    test<int, std::allocator<int> >(2048, -500);
+    test<int, std::allocator<int> >(2049, 654);
+    test<int, std::allocator<int> >(4095, 78);
+    test<int, std::allocator<int> >(4096, 1165);
+    test<int, std::allocator<int> >(4097, 157);
+    test<int, stack_allocator<int, 4096> >(4095, 90);
+}
diff --git a/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..dfcea0b
--- /dev/null
+++ b/test/containers/sequences/deque/deque.cons/size_value_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x, const Allocator& a)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(n, x, a);
+    assert(d.get_allocator() == a);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    std::allocator<int> a;
+    test(0, 5, a);
+    test(1, 10, a);
+    test(10, 11, a);
+    test(1023, -11, a);
+    test(1024, 25, a);
+    test(1025, 0, a);
+    test(2047, 110, a);
+    test(2048, -500, a);
+    test(2049, 654, a);
+    test(4095, 78, a);
+    test(4096, 1165, a);
+    test(4097, 157, a);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..1929a06
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<Emplaceable>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<Emplaceable> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<Emplaceable>& c1)
+{
+    typedef std::deque<Emplaceable> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(*i == Emplaceable(1, 2.5));
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<Emplaceable> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1);
+        }
+    }
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..26a1fb8
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<Emplaceable>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<Emplaceable> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<Emplaceable>& c1)
+{
+    typedef std::deque<Emplaceable> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.emplace_back(Emplaceable(1, 2.5));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.end();
+    assert(*--i == Emplaceable(1, 2.5));
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<Emplaceable> C;
+    C c1 = make(N, start);
+    test(c1);
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..49ac15c
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<Emplaceable>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<Emplaceable> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<Emplaceable>& c1)
+{
+    typedef std::deque<Emplaceable> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.emplace_front(Emplaceable(1, 2.5));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == Emplaceable(1, 2.5));
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<Emplaceable> C;
+    C c1 = make(N, start);
+    test(c1);
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..35afea3
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator p)
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<int>& c1)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    assert(P < c1.size());
+    std::size_t c1_osize = c1.size();
+    I i = c1.erase(c1.cbegin() + P);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    int j = 0;
+    for (; j < P; ++j, ++i)
+        assert(*i == j);
+    for (++j; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+    for (int p = 0; p < N; p += pstep)
+    {
+        C c1 = make(N, start);
+        test(p, c1);
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..e082a05
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator f, const_iterator l)
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<int>& c1, int size)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    assert(P + size <= c1.size());
+    std::size_t c1_osize = c1.size();
+    I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize - size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    int j = 0;
+    for (; j < P; ++j, ++i)
+        assert(*i == j);
+    for (j += size; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+    for (int p = 0; p <= N; p += pstep)
+    {
+        int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
+        for (int s = 0; s <= N - p; s += sstep)
+        {
+            C c1 = make(N, start);
+            test(p, c1, s);
+        }
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..4a5fcea
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<int> d(10, 1);
+    std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..15f9c0f
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,236 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   iterator insert (const_iterator p, InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<int>& c1, const std::deque<int>& c2)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef bidirectional_iterator<CI> BCI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + c2.size());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < c2.size(); ++j, ++i)
+        assert(*i == j);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            test(i, c1, c2);
+        }
+    }
+}
+
+void
+testI(int P, std::deque<int>& c1, const std::deque<int>& c2)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef input_iterator<CI> ICI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + c2.size());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < c2.size(); ++j, ++i)
+        assert(*i == j);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testNI(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            C c2 = make(M);
+            testI(i, c1, c2);
+        }
+    }
+}
+
+void
+test_move()
+{
+#ifdef _LIBCPP_MOVE
+    std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > c;
+    typedef std::deque<MoveOnly>::const_iterator CI;
+    {
+        MoveOnly mo(0);
+        typedef MoveOnly* I;
+        c.insert(c.end(), std::move_iterator<I>(&mo), std::move_iterator<I>(&mo+1));
+    }
+    int j = 0;
+    for (CI i = c.begin(); i != c.end(); ++i, ++j)
+        assert(*i == MoveOnly(j));
+    {
+        MoveOnly mo(1);
+        typedef input_iterator<MoveOnly*> I;
+        c.insert(c.end(), std::move_iterator<I>(I(&mo)), std::move_iterator<I>(I(&mo+1)));
+    }
+    j = 0;
+    for (CI i = c.begin(); i != c.end(); ++i, ++j)
+        assert(*i == MoveOnly(j));
+#endif
+}
+
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+    testNI(1500, 2000, 1000);
+    test_move();
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..b7743f9
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<MoveOnly>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<MoveOnly> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<MoveOnly>& c1, int x)
+{
+    typedef std::deque<MoveOnly> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, MoveOnly(x));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == MoveOnly(j));
+    assert(*i == MoveOnly(x));
+    ++i;
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == MoveOnly(j));
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<MoveOnly> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
new file mode 100644
index 0000000..c94d830
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<int>& c1, int size, int x)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, size, x);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < size; ++j, ++i)
+        assert(*i == x);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+}
+
+void
+self_reference_test()
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    for (int i = 0; i < 20; ++i)
+    {
+        for (int j = 0; j < 20; ++j)
+        {
+            C c = make(20);
+            CI it = c.cbegin() + i;
+            CI jt = c.cbegin() + j;
+            c.insert(it, 5, *jt);
+            assert(c.size() == 25);
+            assert(distance(c.begin(), c.end()) == c.size());
+            it = c.cbegin();
+            for (int k = 0; k < i; ++k, ++it)
+                assert(*it == k);
+            for (int k = 0; k < 5; ++k, ++it)
+                assert(*it == j);
+            for (int k = i; k < 20; ++k, ++it)
+                assert(*it == k);
+        }
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN(rng[i], rng[j], rng[k]);
+    self_reference_test();
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
new file mode 100644
index 0000000..71836d4
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(int P, std::deque<int>& c1, int x)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, x);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    assert(*i == x);
+    ++i;
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make(N, start);
+            test(i, c1, -10);
+        }
+    }
+}
+
+void
+self_reference_test()
+{
+    typedef std::deque<int> C;
+    typedef C::const_iterator CI;
+    for (int i = 0; i < 20; ++i)
+    {
+        for (int j = 0; j < 20; ++j)
+        {
+            C c = make(20);
+            CI it = c.cbegin() + i;
+            CI jt = c.cbegin() + j;
+            c.insert(it, *jt);
+            assert(c.size() == 21);
+            assert(distance(c.begin(), c.end()) == c.size());
+            it = c.cbegin();
+            for (int k = 0; k < i; ++k, ++it)
+                assert(*it == k);
+            assert(*it == j);
+            ++it;
+            for (int k = i; k < 20; ++k, ++it)
+                assert(*it == k);
+        }
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+    self_reference_test();
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
new file mode 100644
index 0000000..0af20b4
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_back()
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.pop_back();
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    for (int j = 0; j < c1.size(); ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    if (N != 0)
+    {
+        typedef std::deque<int> C;
+        C c1 = make(N, start);
+        test(c1);
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..f8ea302
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_front()
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.pop_front();
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    for (int j = 1; j < c1.size(); ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    if (N != 0)
+    {
+        typedef std::deque<int> C;
+        C c1 = make(N, start);
+        test(c1);
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..344a813
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void test(int size)
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+    {
+        std::deque<int> c = make(size, rng[j]);
+        std::deque<int>::const_iterator it = c.begin();
+        for (int i = 0; i < size; ++i, ++it)
+            assert(*it == i);
+    }
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test(rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..bbbfc18
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(value_type&& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<MoveOnly>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<MoveOnly> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void test(int size)
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+    {
+        std::deque<MoveOnly> c = make(size, rng[j]);
+        std::deque<MoveOnly>::const_iterator it = c.begin();
+        for (int i = 0; i < size; ++i, ++it)
+            assert(*it == MoveOnly(i));
+    }
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test(rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
new file mode 100644
index 0000000..fe2b4e4
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/push_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<int>& c1, int x)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.push_front(x);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == x);
+    ++i;
+    for (int j = 0; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    C c1 = make(N, start);
+    test(c1, -10);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 0000000..10804aa
--- /dev/null
+++ b/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifdef _LIBCPP_MOVE
+
+std::deque<MoveOnly>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<MoveOnly> c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void
+test(std::deque<MoveOnly>& c1, int x)
+{
+    typedef std::deque<MoveOnly> C;
+    typedef C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.push_front(MoveOnly(x));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == MoveOnly(x));
+    ++i;
+    for (int j = 0; j < c1_osize; ++j, ++i)
+        assert(*i == MoveOnly(j));
+}
+
+void
+testN(int start, int N)
+{
+    typedef std::deque<MoveOnly> C;
+    C c1 = make(N, start);
+    test(c1, -10);
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+#endif
+}
diff --git a/test/containers/sequences/deque/deque.special/copy.pass.cpp b/test/containers/sequences/deque/deque.special/copy.pass.cpp
new file mode 100644
index 0000000..80200ed
--- /dev/null
+++ b/test/containers/sequences/deque/deque.special/copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   copy(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    typedef input_iterator<CI> ICI;
+    C c1 = make(N, start);
+    C c2 = make(N);
+    assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+    assert(c1 == c2);
+    assert(std::copy(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+    assert(c1 == c2);
+    assert(std::copy(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+    assert(c1 == c2);
+    assert(std::copy(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::copy(ICI(c2.cbegin()), ICI(c2.cend()), c1.begin()) == c1.end());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp
new file mode 100644
index 0000000..aae5e1a
--- /dev/null
+++ b/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   copy_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make(N, start);
+    C c2 = make(N);
+    assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+    assert(c1 == c2);
+    assert(std::copy_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+    assert(c1 == c2);
+    assert(std::copy_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.special/move.pass.cpp b/test/containers/sequences/deque/deque.special/move.pass.cpp
new file mode 100644
index 0000000..4fb2bd3
--- /dev/null
+++ b/test/containers/sequences/deque/deque.special/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   move(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make(N, start);
+    C c2 = make(N);
+    assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+    assert(c1 == c2);
+    assert(std::move(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+    assert(c1 == c2);
+    assert(std::move(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+    assert(c1 == c2);
+    assert(std::move(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::move(RACI(c2.cbegin()), RACI(c2.cend()), c1.begin()) == c1.end());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.special/move_backward.pass.cpp b/test/containers/sequences/deque/deque.special/move_backward.pass.cpp
new file mode 100644
index 0000000..9e5f435
--- /dev/null
+++ b/test/containers/sequences/deque/deque.special/move_backward.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   move_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void testN(int start, int N)
+{
+    typedef std::deque<int> C;
+    typedef C::iterator I;
+    typedef C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make(N, start);
+    C c2 = make(N);
+    assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+    assert(c1 == c2);
+    assert(std::move_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+    assert(c1 == c2);
+    assert(std::move_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN(rng[i], rng[j]);
+}
diff --git a/test/containers/sequences/deque/deque.special/swap.pass.cpp b/test/containers/sequences/deque/deque.special/swap.pass.cpp
new file mode 100644
index 0000000..a3d416c
--- /dev/null
+++ b/test/containers/sequences/deque/deque.special/swap.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class T, class A>
+//   void swap(deque<T, A>& x, deque<T, A>& y);
+
+#include <deque>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+std::deque<int>
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    std::deque<int> c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+void testN(int start, int N, int M)
+{
+    typedef std::deque<int> C;
+    C c1 = make(N, start);
+    C c2 = make(M);
+    C c1_save = c1;
+    C c2_save = c2;
+    swap(c1, c2);
+    assert(c1 == c2_save);
+    assert(c2 == c1_save);
+}
+
+int main()
+{
+    {
+        int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+        const int N = sizeof(rng)/sizeof(rng[0]);
+        for (int i = 0; i < N; ++i)
+            for (int j = 0; j < N; ++j)
+                for (int k = 0; k < N; ++k)
+                    testN(rng[i], rng[j], rng[k]);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/deque/types.pass.cpp b/test/containers/sequences/deque/types.pass.cpp
new file mode 100644
index 0000000..9e2e1bd
--- /dev/null
+++ b/test/containers/sequences/deque/types.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> > 
+// class deque
+// { 
+// public: 
+//     typedef T                                        value_type; 
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <deque>
+#include <iterator>
+#include <type_traits>
+
+#include "../../test_allocator.h"
+#include "../../Copyable.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    typedef std::deque<T, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+    static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+    static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+    static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<int, test_allocator<int> >();
+    test<int*, std::allocator<int*> >();
+    test<Copyable, test_allocator<Copyable> >();
+    static_assert((std::is_same<std::deque<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+}
diff --git a/test/containers/sequences/deque/version.pass.cpp b/test/containers/sequences/deque/version.pass.cpp
new file mode 100644
index 0000000..6e73ad3
--- /dev/null
+++ b/test/containers/sequences/deque/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+#include <deque>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
new file mode 100644
index 0000000..0bd0ce1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// reference       front();
+// const_reference front() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        c.front() = 10;
+        assert(c.front() == 10);
+        assert(*c.begin() == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        assert(*c.begin() == 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
new file mode 100644
index 0000000..333a5b2
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+#include "../../../NotConstructible.h"
+
+int main()
+{
+    {
+        typedef test_allocator<NotConstructible> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        C c = A(12);
+        assert(c.get_allocator() == A(12));
+        assert(c.empty());
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
new file mode 100644
index 0000000..f9309cf
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+#include "../../../NotConstructible.h"
+
+int main()
+{
+    {
+        typedef test_allocator<NotConstructible> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        C c(A(12));
+        assert(c.get_allocator() == A(12));
+        assert(c.empty());
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..c20673b
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(11));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(11));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
new file mode 100644
index 0000000..ac970e1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({10, 11, 12, 13});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..fd0b761
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(11));
+        assert(!c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(11));
+        assert(!c0.empty());
+    }
+
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
new file mode 100644
index 0000000..26281ba
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c = {10, 11, 12, 13};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
new file mode 100644
index 0000000..9c535ff
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     void assign(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
new file mode 100644
index 0000000..aae35ab
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(10, 1);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 1);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(4, 10);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10);
+        assert(n == 4);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
new file mode 100644
index 0000000..fa4ee75
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c = c0;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(10));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c = c0;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(-2));
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..6d62410
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c(c0, A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(9));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c(c0, A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(9));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
new file mode 100644
index 0000000..55cdbe1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list();
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        assert(c.empty());
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
new file mode 100644
index 0000000..696eba1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
new file mode 100644
index 0000000..0baba2d
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c.get_allocator() == A(14));
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
new file mode 100644
index 0000000..22c47be
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c = std::move(c0);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c = std::move(c0);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..16b8f9f
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c(std::move(c0), A(10));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c(std::move(c0), A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(!c0.empty());
+        assert(c.get_allocator() == A(9));
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
new file mode 100644
index 0000000..23082f5
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     forward_list(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
new file mode 100644
index 0000000..42e7183
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     forward_list(InputIterator first, InputIterator last,
+//                  const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "../../../test_allocator.h"
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)), A(13));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c.get_allocator() == A(13));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
new file mode 100644
index 0000000..2c3a4c9
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        unsigned N = 10;
+        C c = N;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifdef _LIBCPP_MOVE
+            assert(*i == T());
+#else
+            ;
+#endif
+        assert(n == N);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
new file mode 100644
index 0000000..6990ace
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        unsigned N = 10;
+        C c(N);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifdef _LIBCPP_MOVE
+            assert(*i == T());
+#else
+            ;
+#endif
+        assert(n == N);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
new file mode 100644
index 0000000..ec1235a
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..486b63c
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v, A(12));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+        assert(c.get_allocator() == A(12));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
new file mode 100644
index 0000000..5c447a7
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator       before_begin();
+// const_iterator before_begin() const;
+// const_iterator cbefore_begin() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.cbefore_begin();
+        assert(std::distance(i, c.end()) == 1);
+        assert(c.cbefore_begin() == c.before_begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+        assert(std::next(c.before_begin()) == c.begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
new file mode 100644
index 0000000..86a0d6b
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C::iterator i;
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..e10aa20
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void clear();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+
+int main()
+{
+    {
+        typedef NotConstructible T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
new file mode 100644
index 0000000..35a45e0
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args>
+//     iterator emplace_after(const_iterator p, Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.emplace_after(c.cbefore_begin());
+        assert(i == c.begin());
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.emplace_after(c.cbegin(), 1, 2.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.emplace_after(c.cbegin(), 3, 4.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+        assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..b831324
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.emplace_front();
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+        c.emplace_front(1, 2.5);
+        assert(c.front() == Emplaceable(1, 2.5));
+        assert(*next(c.begin()) == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
new file mode 100644
index 0000000..5d43a7c
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void erase_after(const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+
+        c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+        assert(distance(c.begin(), c.end()) == 10);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 4);
+        assert(*next(c.begin(), 5) == 5);
+        assert(*next(c.begin(), 6) == 6);
+        assert(*next(c.begin(), 7) == 7);
+        assert(*next(c.begin(), 8) == 8);
+        assert(*next(c.begin(), 9) == 9);
+
+        c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+
+        c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 4);
+        assert(*next(c.begin(), 2) == 5);
+        assert(*next(c.begin(), 3) == 6);
+
+        c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
new file mode 100644
index 0000000..188ad52
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void erase_after(const_iterator p);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.erase_after(next(c.cbefore_begin(), 4));
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+
+        c.erase_after(next(c.cbefore_begin(), 0));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 3);
+
+        c.erase_after(next(c.cbefore_begin(), 1));
+        assert(distance(c.begin(), c.end()) == 2);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 3);
+
+        c.erase_after(next(c.cbefore_begin(), 1));
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(*next(c.begin(), 0) == 1);
+
+        c.erase_after(next(c.cbefore_begin(), 0));
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
new file mode 100644
index 0000000..1d195bc
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
new file mode 100644
index 0000000..b39b243
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), {});
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), {3, 4});
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
new file mode 100644
index 0000000..c3cea9d
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     iterator insert_after(const_iterator p,
+//                           InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        typedef input_iterator<const T*> J;
+        C c;
+        const T t[] = {0, 1, 2, 3, 4};
+        I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), J(t+3), J(t+5));
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
new file mode 100644
index 0000000..02eabb1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
new file mode 100644
index 0000000..18885d9
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0, 0);
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), 3, 3);
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 3);
+
+        i = c.insert_after(c.begin(), 2, 2);
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 3);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..44f7c40
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void pop_front();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
new file mode 100644
index 0000000..7dfe931
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
new file mode 100644
index 0000000..a6a439d
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#endif
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
new file mode 100644
index 0000000..293427d
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+        c.resize(10);
+        assert(distance(c.begin(), c.end()) == 10);
+        c.resize(20);
+        assert(distance(c.begin(), c.end()) == 20);
+        c.resize(5);
+        assert(distance(c.begin(), c.end()) == 5);
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
new file mode 100644
index 0000000..9698fd6
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3, 10);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6, 10);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+
+        c.resize(6, 12);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
new file mode 100644
index 0000000..438bd6c
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/merge.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void merge(forward_list&& x);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {3, 5, 6, 7, 12, 13};
+        const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+        const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2);
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
new file mode 100644
index 0000000..5123084
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void merge(forward_list&& x, Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {13, 12, 7, 6, 5, 3};
+        const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+        const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2, std::greater<T>());
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
new file mode 100644
index 0000000..d68078c
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/remove.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void remove(const value_type& v);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
new file mode 100644
index 0000000..9a85d95
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Predicate> void remove_if(Predicate pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+bool g(int i)
+{
+    return i < 3;
+}
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
new file mode 100644
index 0000000..2516f51
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/reverse.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void reverse();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+void test(int N)
+{
+    typedef int T;
+    typedef std::forward_list<T> C;
+    C c;
+    for (int i = 0; i < N; ++i)
+        c.push_front(i);
+    c.reverse();
+    assert(distance(c.begin(), c.end()) == N);
+    C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == i);
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        test(i);
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
new file mode 100644
index 0000000..79b0109
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void sort();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+void test(int N)
+{
+    typedef int T;
+    typedef std::forward_list<T> C;
+    typedef std::vector<T> V;
+    V v;
+    for (int i = 0; i < N; ++i)
+        v.push_back(i);
+    std::random_shuffle(v.begin(), v.end());
+    C c(v.begin(), v.end());
+    c.sort();
+    assert(distance(c.begin(), c.end()) == N);
+    C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == i);
+}
+
+int main()
+{
+    for (int i = 0; i < 40; ++i)
+        test(i);
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
new file mode 100644
index 0000000..b220e17
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void sort(Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+void test(int N)
+{
+    typedef int T;
+    typedef std::forward_list<T> C;
+    typedef std::vector<T> V;
+    V v;
+    for (int i = 0; i < N; ++i)
+        v.push_back(i);
+    std::random_shuffle(v.begin(), v.end());
+    C c(v.begin(), v.end());
+    c.sort(std::greater<T>());
+    assert(distance(c.begin(), c.end()) == N);
+    C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == N-1-i);
+}
+
+int main()
+{
+    for (int i = 0; i < 40; ++i)
+        test(i);
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
new file mode 100644
index 0000000..a169294
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+typedef int T;
+typedef std::forward_list<T> C;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+void
+testd(const C& c, int p, int l)
+{
+    C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = 0; n2 < l; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + l);
+}
+
+int main()
+{
+    // splicing different containers
+    for (int l = 0; l <= size_t2; ++l)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(t2, t2+l);
+    
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+            testd(c1, p, l);
+        }
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
new file mode 100644
index 0000000..08c365e
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+typedef int T;
+typedef std::forward_list<T> C;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+void
+testd(const C& c, int p, int f)
+{
+    C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = f; n2 < f+1; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + 1);
+}
+
+void
+tests(const C& c, int p, int f)
+{
+    C::const_iterator i = c.begin();
+    int n = 0;
+    int d = 1;
+    if (p == f || p == f+1)
+    {
+        for (n = 0; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else if (p < f)
+    {
+        for (n = 0; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < f+1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f+1; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else // p > f+1
+    {
+        for (n = 0; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f+1; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < f+1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+    // splicing different containers
+    for (int f = 0; f <= size_t2-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(std::begin(t2), std::end(t2));
+    
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                  next(c2.cbefore_begin(), f));
+            testd(c1, p, f);
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+    
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                  next(c1.cbefore_begin(), f));
+            tests(c1, p, f);
+        }
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
new file mode 100644
index 0000000..2aac66a
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x,
+//                   const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+typedef int T;
+typedef std::forward_list<T> C;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+void
+testd(const C& c, int p, int f, int l)
+{
+    C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = f; n2 < l-1; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0));
+}
+
+void
+tests(const C& c, int p, int f, int l)
+{
+    C::const_iterator i = c.begin();
+    int n = 0;
+    int d = l > f+1 ? l-1-f : 0;
+    if (d == 0 || p == f)
+    {
+        for (n = 0; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else if (p < f)
+    {
+        for (n = 0; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < l-1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = l-1; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else // p > f
+    {
+        for (n = 0; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = l-1; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < l-1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+    // splicing different containers
+    for (int f = 0; f <= size_t2+1; ++f)
+    {
+        for (int l = f; l <= size_t2+1; ++l)
+        {
+            for (int p = 0; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+                C c2(std::begin(t2), std::end(t2));
+        
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                      next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+                testd(c1, p, f, l);
+            }
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1+1; ++f)
+    {
+        for (int l = f; l <= size_t1; ++l)
+        {
+            for (int p = 0; p <= f; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+        
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+            for (int p = l; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+        
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+        }
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
new file mode 100644
index 0000000..bed53ec
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void unique();
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
new file mode 100644
index 0000000..d7d8543
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+bool g(int x, int y)
+{
+    return x == y;
+}
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
new file mode 100644
index 0000000..c4b3f37
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     bool operator==(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+// 
+// template <class T, class Allocator>
+//     bool operator!=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+void test(int N, int M)
+{
+    typedef int T;
+    typedef std::forward_list<T> C;
+    C c1;
+    for (int i = 0; i < N; ++i)
+        c1.push_front(i);
+    C c2;
+    for (int i = 0; i < M; ++i)
+        c2.push_front(i);
+    if (N == M)
+        assert(c1 == c2);
+    else
+        assert(c1 != c2);
+    c2 = c1;
+    assert(c1 == c2);
+    if (N > 0)
+    {
+        c2.front() = N+1;
+        assert(c1 != c2);
+    }
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test(i, j);
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
new file mode 100644
index 0000000..561c4b1
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
@@ -0,0 +1,178 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
new file mode 100644
index 0000000..69c50eb
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
new file mode 100644
index 0000000..33c2bbc
--- /dev/null
+++ b/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     bool operator< (const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+// 
+// template <class T, class Allocator>
+//     bool operator> (const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+// 
+// template <class T, class Allocator>
+//     bool operator>=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+// 
+// template <class T, class Allocator>
+//     bool operator<=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+void test(int N, int M)
+{
+    typedef int T;
+    typedef std::forward_list<T> C;
+    C c1;
+    for (int i = 0; i < N; ++i)
+        c1.push_front(i);
+    C c2;
+    for (int i = 0; i < M; ++i)
+        c2.push_front(i);
+    if (N < M)
+        assert(c1 < c2);
+    if (N <= M)
+        assert(c1 <= c2);
+    if (N >= M)
+        assert(c1 >= c2);
+    if (N > M)
+        assert(c1 > c2);
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test(i, j);
+}
diff --git a/test/containers/sequences/forwardlist/max_size.pass.cpp b/test/containers/sequences/forwardlist/max_size.pass.cpp
new file mode 100644
index 0000000..b42ff86
--- /dev/null
+++ b/test/containers/sequences/forwardlist/max_size.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// size_type max_size() const;
+
+#include <forward_list>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        assert(c.max_size() > 0);
+    }
+}
diff --git a/test/containers/sequences/forwardlist/types.pass.cpp b/test/containers/sequences/forwardlist/types.pass.cpp
new file mode 100644
index 0000000..814bca7
--- /dev/null
+++ b/test/containers/sequences/forwardlist/types.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator = allocator<T>>
+// class forward_list
+// {
+// public:
+//   typedef T         value_type;
+//   typedef Allocator allocator_type;
+// 
+//   typedef value_type&                                                reference;
+//   typedef const value_type&                                          const_reference;
+//   typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//   typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//   typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//   typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+//   ...
+// };
+
+#include <forward_list>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::forward_list<char>::value_type, char>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::allocator_type, std::allocator<char> >::value), "");
+    static_assert((std::is_same<std::forward_list<char>::reference, char&>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::const_reference, const char&>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::pointer, char*>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::forward_list<char>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/containers/sequences/forwardlist/version.pass.cpp b/test/containers/sequences/forwardlist/version.pass.cpp
new file mode 100644
index 0000000..d91bd74
--- /dev/null
+++ b/test/containers/sequences/forwardlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/list/list.capacity/resize_size.pass.cpp b/test/containers/sequences/list/list.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..2369a5f
--- /dev/null
+++ b/test/containers/sequences/list/list.capacity/resize_size.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz);
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        std::list<int> l(5, 2);
+        l.resize(2);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert(l == std::list<int>(2, 2));
+    }
+    {
+        std::list<int> l(5, 2);
+        l.resize(10);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 0);
+    }
+#ifdef __LIBCPP_MOVE
+    {
+        std::list<DefaultOnly> l(10);
+        l.resize(5);
+        assert(l.size() == 5);
+        assert(std::distance(l.begin(), l.end()) == 5);
+    }
+    {
+        std::list<DefaultOnly> l(10);
+        l.resize(20);
+        assert(l.size() == 20);
+        assert(std::distance(l.begin(), l.end()) == 20);
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..3eca805
--- /dev/null
+++ b/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        std::list<double> l(5, 2);
+        l.resize(2, 3.5);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert(l == std::list<double>(2, 2));
+    }
+    {
+        std::list<double> l(5, 2);
+        l.resize(10, 3.5);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 3.5);
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/assign_copy.pass.cpp b/test/containers/sequences/list/list.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..bca800d
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(const list& c);
+
+#include <list>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..eb7a50e
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/containers/sequences/list/list.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..2c2ec53
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/copy.pass.cpp b/test/containers/sequences/list/list.cons/copy.pass.cpp
new file mode 100644
index 0000000..3a563eb
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/copy.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c);
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(3, 2);
+        std::list<int> l2 = l;
+        assert(l2 == l);
+    }
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == l.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(-2));
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..9c94123
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(3));
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/default.pass.cpp b/test/containers/sequences/list/list.cons/default.pass.cpp
new file mode 100644
index 0000000..579c3aa
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+
+int main()
+{
+    {
+        std::list<int> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<DefaultOnly> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int> l((std::allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
new file mode 100644
index 0000000..e6e11e2
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/default_stack_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+#include <iostream>
+
+int main()
+{
+    {
+        std::list<int> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int> l((std::allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int, stack_allocator<int, 4> > l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/containers/sequences/list/list.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..14d1a79
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..6f00e2f
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <list>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/containers/sequences/list/list.cons/input_iterator.pass.cpp
new file mode 100644
index 0000000..e740b3e
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class InputIterator> 
+//   list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "../../../iterators.h"
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+                         std::allocator<int>());
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+}
diff --git a/test/containers/sequences/list/list.cons/move.pass.cpp b/test/containers/sequences/list/list.cons/move.pass.cpp
new file mode 100644
index 0000000..189d637
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/move.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/containers/sequences/list/list.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..4f5779e
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..4ce3e5d
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/size_type.pass.cpp b/test/containers/sequences/list/list.cons/size_type.pass.cpp
new file mode 100644
index 0000000..4a96822
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(size_type n);
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+    }
+    {
+        std::list<int, stack_allocator<int, 3> > l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        std::list<DefaultOnly> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+    }
+#endif
+}
diff --git a/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..34c9f7e
--- /dev/null
+++ b/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(size_type n, const T& value, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "../../../DefaultOnly.h"
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(3, 2);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l(3, 2, std::allocator<int>());
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, stack_allocator<int, 3> > l(3, 2);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+}
diff --git a/test/containers/sequences/list/list.modifiers/clear.pass.cpp b/test/containers/sequences/list/list.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..1ebe348
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/clear.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void clear();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.clear();
+    assert(c.empty());
+}
diff --git a/test/containers/sequences/list/list.modifiers/emplace.pass.cpp b/test/containers/sequences/list/list.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..60d5bc1
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/emplace.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+#include <list>
+#include <cassert>
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<A> c;
+    c.emplace(c.cbegin(), 2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace(c.cend(), 3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..7d18379
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<A> c;
+    c.emplace_back(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_back(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..f60c492
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<A> c;
+    c.emplace_front(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_front(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 3);
+    assert(c.front().getd() == 4.5);
+    assert(c.back().geti() == 2);
+    assert(c.back().getd() == 3.5);
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..16b725f
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator position);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::const_iterator i = l1.begin();
+    ++i;
+    std::list<int>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+}
diff --git a/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..6296541
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::list<int>(a1+1, a1+3));
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::list<int>(a1+2, a1+3));
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+}
diff --git a/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..cdbe902
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<int> d(10, 1);
+    std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == next(d.begin(), 2));
+    i = d.begin();
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..31c057f
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter> 
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    std::list<int> l1;
+    std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+    assert(i == l1.begin());
+    assert(l1.size() == 3);
+    assert(distance(l1.begin(), l1.end()) == 3);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 3);
+    int a2[] = {4, 5, 6};
+    i = l1.insert(i, a2, a2+3);
+    assert(*i == 4);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+    throw_next = 2;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, a2, a2+3);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    assert(save_count == count);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+}
diff --git a/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 0000000..1a1c97d
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<MoveOnly> l1;
+    l1.insert(l1.cend(), MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.insert(l1.cbegin(), MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..ec9b0e9
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+    assert(i == next(l1.begin()));
+    assert(l1 == std::list<int>(a2, a2+8));
+    throw_next = 4;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert(l1 == std::list<int>(a2, a2+8));
+}
diff --git a/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..02d2cd1
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4);
+    assert(i == next(l1.begin()));
+    assert(l1.size() == 4);
+    assert(distance(l1.begin(), l1.end()) == 4);
+    assert(l1 == std::list<int>(a2, a2+4));
+    throw_next = 0;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert(l1 == std::list<int>(a2, a2+4));
+}
diff --git a/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp
new file mode 100644
index 0000000..14deedb
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_back();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.pop_back();
+    assert(c == std::list<int>(a, a+2));
+    c.pop_back();
+    assert(c == std::list<int>(a, a+1));
+    c.pop_back();
+    assert(c.empty());
+}
diff --git a/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..159bc76
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_front();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.pop_front();
+    assert(c == std::list<int>(a+1, a+3));
+    c.pop_front();
+    assert(c == std::list<int>(a+2, a+3));
+    c.pop_front();
+    assert(c.empty());
+}
diff --git a/test/containers/sequences/list/list.modifiers/push_back.pass.cpp b/test/containers/sequences/list/list.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..8a1970a
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/push_back.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    std::list<int> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_back(i);
+    int a[] = {0, 1, 2, 3, 4};
+    assert(c == std::list<int>(a, a+5));
+}
diff --git a/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..f51f05d
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<MoveOnly> l1;
+    l1.push_back(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_back(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(1));
+    assert(l1.back() == MoveOnly(2));
+#endif
+}
diff --git a/test/containers/sequences/list/list.modifiers/push_front.pass.cpp b/test/containers/sequences/list/list.modifiers/push_front.pass.cpp
new file mode 100644
index 0000000..5a71f33
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/push_front.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    std::list<int> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_front(i);
+    int a[] = {4, 3, 2, 1, 0};
+    assert(c == std::list<int>(a, a+5));
+}
diff --git a/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 0000000..8f2773e
--- /dev/null
+++ b/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::list<MoveOnly> l1;
+    l1.push_front(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_front(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+#endif
+}
diff --git a/test/containers/sequences/list/list.ops/merge.pass.cpp b/test/containers/sequences/list/list.ops/merge.pass.cpp
new file mode 100644
index 0000000..75eb573
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/merge.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void merge(list& x);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 3, 7, 9, 10};
+    int a2[] = {0, 2, 4, 5, 6, 8, 11};
+    int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2);
+    assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+}
diff --git a/test/containers/sequences/list/list.ops/merge_comp.pass.cpp b/test/containers/sequences/list/list.ops/merge_comp.pass.cpp
new file mode 100644
index 0000000..6ef125d
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/merge_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> void merge(list& x, Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {10, 9, 7, 3, 1};
+    int a2[] = {11, 8, 6, 5, 4, 2, 0};
+    int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2, std::greater<int>());
+    assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+}
diff --git a/test/containers/sequences/list/list.ops/remove.pass.cpp b/test/containers/sequences/list/list.ops/remove.pass.cpp
new file mode 100644
index 0000000..4896d42
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/remove.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void remove(const value_type& value);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {1, 2, 4};
+    std::list<int> c(a1, a1+4);
+    c.remove(3);
+    assert(c == std::list<int>(a2, a2+3));
+}
diff --git a/test/containers/sequences/list/list.ops/remove_if.pass.cpp b/test/containers/sequences/list/list.ops/remove_if.pass.cpp
new file mode 100644
index 0000000..e35984f
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Pred> void remove_if(Pred pred);
+
+#include <list>
+#include <cassert>
+#include <functional>
+
+bool g(int i)
+{
+    return i < 3;
+}
+
+int main()
+{
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {3, 4};
+    std::list<int> c(a1, a1+4);
+    c.remove_if(g);
+    assert(c == std::list<int>(a2, a2+2));
+}
diff --git a/test/containers/sequences/list/list.ops/reverse.pass.cpp b/test/containers/sequences/list/list.ops/reverse.pass.cpp
new file mode 100644
index 0000000..2cdbcde
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/reverse.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void reverse();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.reverse();
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+}
diff --git a/test/containers/sequences/list/list.ops/sort.pass.cpp b/test/containers/sequences/list/list.ops/sort.pass.cpp
new file mode 100644
index 0000000..0c1ec4f
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/sort.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void sort();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort();
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+}
diff --git a/test/containers/sequences/list/list.ops/sort_comp.pass.cpp b/test/containers/sequences/list/list.ops/sort_comp.pass.cpp
new file mode 100644
index 0000000..1a75778
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/sort_comp.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> sort(Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort(std::greater<int>());
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+}
diff --git a/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
new file mode 100644
index 0000000..9f7d299
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
@@ -0,0 +1,400 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1;
+        std::list<int> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 0);
+        assert(distance(l1.begin(), l1.end()) == 0);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 3), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+}
diff --git a/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
new file mode 100644
index 0000000..429c43d
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 6);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+}
diff --git a/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
new file mode 100644
index 0000000..82fa37f
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+}
diff --git a/test/containers/sequences/list/list.ops/unique.pass.cpp b/test/containers/sequences/list/list.ops/unique.pass.cpp
new file mode 100644
index 0000000..9a547f1
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/unique.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void unique();
+
+#include <list>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique();
+    assert(c == std::list<int>(a2, a2+4));
+}
diff --git a/test/containers/sequences/list/list.ops/unique_pred.pass.cpp b/test/containers/sequences/list/list.ops/unique_pred.pass.cpp
new file mode 100644
index 0000000..2800baa
--- /dev/null
+++ b/test/containers/sequences/list/list.ops/unique_pred.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class BinaryPred> void unique(BinaryPred pred);
+
+#include <list>
+#include <cassert>
+
+bool g(int x, int y)
+{
+    return x == y;
+}
+
+int main()
+{
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique(g);
+    assert(c == std::list<int>(a2, a2+4));
+}
diff --git a/test/containers/sequences/list/list.special/swap.pass.cpp b/test/containers/sequences/list/list.special/swap.pass.cpp
new file mode 100644
index 0000000..6ca9c57
--- /dev/null
+++ b/test/containers/sequences/list/list.special/swap.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+//   void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+
+#include <list>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1);
+        std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1);
+        std::list<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/list/types.pass.cpp b/test/containers/sequences/list/types.pass.cpp
new file mode 100644
index 0000000..7834b1c
--- /dev/null
+++ b/test/containers/sequences/list/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc = allocator<T> >
+// class list
+// {
+// public:
+// 
+//     // types:
+//     typedef T value_type;
+//     typedef Alloc allocator_type;
+//     typedef typename allocator_type::reference reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer pointer;
+//     typedef typename allocator_type::const_pointer const_pointer;
+
+#include <list>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
+    static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
+    static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+}
diff --git a/test/containers/sequences/list/version.pass.cpp b/test/containers/sequences/list/version.pass.cpp
new file mode 100644
index 0000000..9c386f3
--- /dev/null
+++ b/test/containers/sequences/list/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/sequences/nothing_to_do.pass.cpp b/test/containers/sequences/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/containers/sequences/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/containers/sequences/vector.bool/assign_copy.pass.cpp b/test/containers/sequences/vector.bool/assign_copy.pass.cpp
new file mode 100644
index 0000000..149fca6
--- /dev/null
+++ b/test/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<bool>(3));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<bool>(5));
+    }
+}
diff --git a/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..387b227
--- /dev/null
+++ b/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d;
+    d.assign({true, false, false, true});
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/assign_move.pass.cpp b/test/containers/sequences/vector.bool/assign_move.pass.cpp
new file mode 100644
index 0000000..41cbc1f
--- /dev/null
+++ b/test/containers/sequences/vector.bool/assign_move.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(6));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/capacity.pass.cpp b/test/containers/sequences/vector.bool/capacity.pass.cpp
new file mode 100644
index 0000000..0263ec4
--- /dev/null
+++ b/test/containers/sequences/vector.bool/capacity.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v;
+        assert(v.capacity() == 0);
+    }
+    {
+        std::vector<bool> v(100);
+        assert(v.capacity() >= 100);
+        v.push_back(0);
+        assert(v.capacity() >= 101);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/construct_default.pass.cpp b/test/containers/sequences/vector.bool/construct_default.pass.cpp
new file mode 100644
index 0000000..45368c6
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+template <class C>
+void
+test0()
+{
+    C c;
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == typename C::allocator_type());
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+    C c(a);
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == a);
+}
+
+int main()
+{
+    {
+    test0<std::vector<bool> >();
+    test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
+    }
+}
diff --git a/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
new file mode 100644
index 0000000..5cc617c
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+    C c(first, last);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+    bool* an = a + sizeof(a)/sizeof(a[0]);
+    test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+    test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+    test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+    test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+    test<std::vector<bool> >(a, an);
+}
diff --git a/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..56d884f
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+//                                   const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+    C c(first, last, a);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+    bool* an = a + sizeof(a)/sizeof(a[0]);
+    std::allocator<bool> alloc;
+    test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(a, an, alloc);
+}
diff --git a/test/containers/sequences/vector.bool/construct_size.pass.cpp b/test/containers/sequences/vector.bool/construct_size.pass.cpp
new file mode 100644
index 0000000..f4e5400
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+    C c(n);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == typename C::allocator_type());
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+}
+
+int main()
+{
+    test<std::vector<bool> >(50);
+}
diff --git a/test/containers/sequences/vector.bool/construct_size_value.pass.cpp b/test/containers/sequences/vector.bool/construct_size_value.pass.cpp
new file mode 100644
index 0000000..0411292
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+    C c(n, x);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<bool> >(50, 3);
+}
diff --git a/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
new file mode 100644
index 0000000..9f404e9
--- /dev/null
+++ b/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+     const typename C::allocator_type& a)
+{
+    C c(n, x, a);
+    assert(c.__invariants());
+    assert(a == c.get_allocator());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<bool> >(50, 3, std::allocator<bool>());
+}
diff --git a/test/containers/sequences/vector.bool/copy.pass.cpp b/test/containers/sequences/vector.bool/copy.pass.cpp
new file mode 100644
index 0000000..41de818
--- /dev/null
+++ b/test/containers/sequences/vector.bool/copy.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    unsigned s = x.size();
+    C c(x);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+        bool* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool>(a, an));
+    }
+    {
+        std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<bool>(-2));
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/copy_alloc.pass.cpp b/test/containers/sequences/vector.bool/copy_alloc.pass.cpp
new file mode 100644
index 0000000..8134c67
--- /dev/null
+++ b/test/containers/sequences/vector.bool/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    unsigned s = x.size();
+    C c(x, a);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool>(a, an), std::allocator<bool>());
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<bool>(3));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<bool>(3));
+    }
+}
diff --git a/test/containers/sequences/vector.bool/erase_iter.pass.cpp b/test/containers/sequences/vector.bool/erase_iter.pass.cpp
new file mode 100644
index 0000000..700d567
--- /dev/null
+++ b/test/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    bool a1[] = {1, 0, 1};
+    std::vector<bool> l1(a1, a1+3);
+    std::vector<bool>::const_iterator i = l1.begin();
+    ++i;
+    std::vector<bool>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == true);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == true);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == true);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+}
diff --git a/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..0f82b43
--- /dev/null
+++ b/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    bool a1[] = {1, 0, 1};
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<bool>(a1+1, a1+3));
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<bool>(a1+2, a1+3));
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+}
diff --git a/test/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/containers/sequences/vector.bool/initializer_list.pass.cpp
new file mode 100644
index 0000000..c7c29ac
--- /dev/null
+++ b/test/containers/sequences/vector.bool/initializer_list.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..34edd55
--- /dev/null
+++ b/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int, test_allocator<int>> d({true, false, false, true}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..ab85aaf
--- /dev/null
+++ b/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<bool> d(10, true);
+    std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == true);
+    assert(d[1] == true);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    assert(d[4] == true);
+    assert(d[5] == false);
+    assert(d[6] == true);
+    assert(d[7] == true);
+    assert(d[8] == true);
+    assert(d[9] == true);
+    assert(d[10] == true);
+    assert(d[11] == true);
+    assert(d[12] == true);
+    assert(d[13] == true);
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..9b275a9
--- /dev/null
+++ b/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class Iter> 
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const bool N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+                                        input_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<bool> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const bool N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+                                        forward_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..47f55d2
--- /dev/null
+++ b/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..6ab35a3
--- /dev/null
+++ b/test/containers/sequences/vector.bool/insert_iter_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/move.pass.cpp b/test/containers/sequences/vector.bool/move.pass.cpp
new file mode 100644
index 0000000..f1d4ce3
--- /dev/null
+++ b/test/containers/sequences/vector.bool/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/containers/sequences/vector.bool/move_alloc.pass.cpp
new file mode 100644
index 0000000..d07102f
--- /dev/null
+++ b/test/containers/sequences/vector.bool/move_alloc.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(6));
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(5));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<bool>(4));
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..bd9e194
--- /dev/null
+++ b/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<bool> d;
+    d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+#endif
+}
diff --git a/test/containers/sequences/vector.bool/push_back.pass.cpp b/test/containers/sequences/vector.bool/push_back.pass.cpp
new file mode 100644
index 0000000..af8199b
--- /dev/null
+++ b/test/containers/sequences/vector.bool/push_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        bool a[] = {0, 1, 1, 0, 1, 0, 0};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<int> c;
+        for (unsigned i = 0; i < N; ++i)
+        {
+            c.push_back(a[i]);
+            assert(c.size() == i+1);
+            for (int j = 0; j < c.size(); ++j)
+                assert(c[j] == a[j]);
+        }
+    }
+}
diff --git a/test/containers/sequences/vector.bool/reserve.pass.cpp b/test/containers/sequences/vector.bool/reserve.pass.cpp
new file mode 100644
index 0000000..5761980
--- /dev/null
+++ b/test/containers/sequences/vector.bool/reserve.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+    }
+    {
+        std::vector<bool> v(100);
+        assert(v.capacity() >= 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 150);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/resize_size.pass.cpp b/test/containers/sequences/vector.bool/resize_size.pass.cpp
new file mode 100644
index 0000000..3d573d1
--- /dev/null
+++ b/test/containers/sequences/vector.bool/resize_size.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/resize_size_value.pass.cpp b/test/containers/sequences/vector.bool/resize_size_value.pass.cpp
new file mode 100644
index 0000000..ccf06c0
--- /dev/null
+++ b/test/containers/sequences/vector.bool/resize_size_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        assert(v == std::vector<bool>(50));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..8e609fb
--- /dev/null
+++ b/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() >= 101);
+        assert(v.size() >= 101);
+    }
+}
diff --git a/test/containers/sequences/vector.bool/swap.pass.cpp b/test/containers/sequences/vector.bool/swap.pass.cpp
new file mode 100644
index 0000000..3170831
--- /dev/null
+++ b/test/containers/sequences/vector.bool/swap.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v1(100);
+        std::vector<bool> v2(200);
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+    }
+    {
+        typedef test_allocator<bool> A;
+        std::vector<bool, A> v1(100, true, A(1));
+        std::vector<bool, A> v2(200, false, A(2));
+        swap(v1, v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+        assert(v1.get_allocator() == A(1));
+        assert(v2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<bool> A;
+        std::vector<bool, A> v1(100, true, A(1));
+        std::vector<bool, A> v2(200, false, A(2));
+        swap(v1, v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+        assert(v1.get_allocator() == A(2));
+        assert(v2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/vector.bool/types.pass.cpp b/test/containers/sequences/vector.bool/types.pass.cpp
new file mode 100644
index 0000000..1713740
--- /dev/null
+++ b/test/containers/sequences/vector.bool/types.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class Allocator> 
+// class vector<bool, Allocator
+// { 
+// public: 
+//     typedef T                                        value_type; 
+//     typedef Allocator                                allocator_type;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "../../test_allocator.h"
+#include "../../Copyable.h"
+
+template <class Allocator>
+void
+test()
+{
+    typedef std::vector<bool, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, bool>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<test_allocator<bool> >();
+    test<std::allocator<bool> >();
+    static_assert((std::is_same<std::vector<bool>::allocator_type,
+                                std::allocator<bool> >::value), "");
+}
diff --git a/test/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/containers/sequences/vector.bool/vector_bool.pass.cpp
new file mode 100644
index 0000000..03df8e0
--- /dev/null
+++ b/test/containers/sequences/vector.bool/vector_bool.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <vector>
+#include <cassert>
+#include <type_traits>
+
+int main()
+{
+    typedef std::vector<bool> T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    bool ba[] = {true, false, true, true, false};
+    T vb(std::begin(ba), std::end(ba));
+    H h;
+    assert(h(vb) != 0);
+}
diff --git a/test/containers/sequences/vector/types.pass.cpp b/test/containers/sequences/vector/types.pass.cpp
new file mode 100644
index 0000000..f7f2503
--- /dev/null
+++ b/test/containers/sequences/vector/types.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> > 
+// class vector
+// { 
+// public: 
+//     typedef T                                        value_type; 
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "../../test_allocator.h"
+#include "../../Copyable.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    typedef std::vector<T, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+    static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+    static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+    static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<int, test_allocator<int> >();
+    test<int*, std::allocator<int*> >();
+    test<Copyable, test_allocator<Copyable> >();
+    static_assert((std::is_same<std::vector<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+}
diff --git a/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp
new file mode 100644
index 0000000..d8c2f36
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<int> v;
+        assert(v.capacity() == 0);
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.capacity() == 100);
+        v.push_back(0);
+        assert(v.capacity() > 101);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp
new file mode 100644
index 0000000..e57dc84
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.capacity() == 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() == 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() == 150);
+    }
+    {
+        std::vector<int, stack_allocator<int, 250> > v(100);
+        assert(v.capacity() == 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() == 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() == 150);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..07ad128
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+#else
+    {
+        std::vector<int> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..9c5d818
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(v == std::vector<int>(50));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..e0dd07f
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() == 101);
+        assert(v.size() == 101);
+    }
+    {
+        std::vector<int, stack_allocator<int, 401> > v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() == 101);
+        assert(v.size() == 101);
+    }
+    {
+        std::vector<int, stack_allocator<int, 400> > v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() == 200);
+        assert(v.size() == 101);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.capacity/swap.pass.cpp b/test/containers/sequences/vector/vector.capacity/swap.pass.cpp
new file mode 100644
index 0000000..a467796
--- /dev/null
+++ b/test/containers/sequences/vector/vector.capacity/swap.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<int> v1(100);
+        std::vector<int> v2(200);
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() == 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() == 100);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..7a41e7e
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+}
diff --git a/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..75d11f4
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..2a22c2b
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp
new file mode 100644
index 0000000..a2bdbff
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "../../../stack_allocator.h"
+
+template <class C>
+void
+test0()
+{
+    C c;
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == typename C::allocator_type());
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+    C c(a);
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == a);
+}
+
+int main()
+{
+    {
+    test0<std::vector<int> >();
+    test0<std::vector<NotConstructible> >();
+    test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
+    test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
+        (test_allocator<NotConstructible>(5));
+    }
+    {
+        std::vector<int, stack_allocator<int, 10> > v;
+        assert(v.empty());
+    }
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
new file mode 100644
index 0000000..305b484
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../stack_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+    C c(first, last);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+    test<std::vector<int> >(a, an);
+
+    test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..eea5103
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+//                                   const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../stack_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+    C c(first, last, a);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::allocator<int> alloc;
+    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(a, an, alloc);
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp
new file mode 100644
index 0000000..3ebdc07
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../DefaultOnly.h"
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+    C c(n);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == typename C::allocator_type());
+#ifdef _LIBCPP_MOVE
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+#endif
+}
+
+int main()
+{
+    test<std::vector<int> >(50);
+    test<std::vector<DefaultOnly> >(500);
+    assert(DefaultOnly::count == 0);
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
new file mode 100644
index 0000000..0755b59
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+    C c(n, x);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<int> >(50, 3);
+    test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+}
diff --git a/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
new file mode 100644
index 0000000..b9a6477
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+     const typename C::allocator_type& a)
+{
+    C c(n, x, a);
+    assert(c.__invariants());
+    assert(a == c.get_allocator());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<int> >(50, 3, std::allocator<int>());
+}
diff --git a/test/containers/sequences/vector/vector.cons/copy.pass.cpp b/test/containers/sequences/vector/vector.cons/copy.pass.cpp
new file mode 100644
index 0000000..04c6efc
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    unsigned s = x.size();
+    C c(x);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int>(a, an));
+    }
+    {
+        std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<int>(-2));
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..74d179b
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    unsigned s = x.size();
+    C c(x, a);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int>(a, an), std::allocator<int>());
+    }
+    {
+        std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(3));
+    }
+}
diff --git a/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..4ad07ca
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..77b1103
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/move.pass.cpp b/test/containers/sequences/vector/vector.cons/move.pass.cpp
new file mode 100644
index 0000000..cc313df
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/move.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..7218ce9
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..72ac2d3
--- /dev/null
+++ b/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.data/data.pass.cpp b/test/containers/sequences/vector/vector.data/data.pass.cpp
new file mode 100644
index 0000000..e24be72
--- /dev/null
+++ b/test/containers/sequences/vector/vector.data/data.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// pointer data();
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::vector<int> v;
+        assert(v.data() == 0);
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.data() == &v.front());
+    }
+}
diff --git a/test/containers/sequences/vector/vector.data/data_const.pass.cpp b/test/containers/sequences/vector/vector.data/data_const.pass.cpp
new file mode 100644
index 0000000..1de53c0
--- /dev/null
+++ b/test/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// const_pointer data() const;
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::vector<int> v;
+        assert(v.data() == 0);
+    }
+    {
+        const std::vector<int> v(100);
+        assert(v.data() == &v.front());
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..762b16d
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+#ifdef _LIBCPP_MOVE
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    A(A&& a)
+        : i_(a.i_),
+          d_(a.d_)
+    {
+        a.i_ = 0;
+        a.d_ = 0;
+    }
+
+    A& operator=(A&& a)
+    {
+        i_ = a.i_;
+        d_ = a.d_;
+        a.i_ = 0;
+        a.d_ = 0;
+        return *this;
+    }
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<A> c;
+        std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        i = c.emplace(c.cend(), 3, 4.5);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        i = c.emplace(c.cbegin()+1, 4, 6.5);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c[1].geti() == 4);
+        assert(c[1].getd() == 6.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+    }
+    {
+        std::vector<A, stack_allocator<A, 7> > c;
+        std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        i = c.emplace(c.cend(), 3, 4.5);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        i = c.emplace(c.cbegin()+1, 4, 6.5);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c[1].geti() == 4);
+        assert(c[1].getd() == 6.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..86b28a1
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+#ifdef _LIBCPP_MOVE
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    A(A&& a)
+        : i_(a.i_),
+          d_(a.d_)
+    {
+        a.i_ = 0;
+        a.d_ = 0;
+    }
+
+    A& operator=(A&& a)
+    {
+        i_ = a.i_;
+        d_ = a.d_;
+        a.i_ = 0;
+        a.d_ = 0;
+        return *this;
+    }
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<A> c;
+        c.emplace_back(2, 3.5);
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        c.emplace_back(3, 4.5);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+    }
+    {
+        std::vector<A, stack_allocator<A, 4> > c;
+        c.emplace_back(2, 3.5);
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        c.emplace_back(3, 4.5);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..1cfa63f
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int>::const_iterator i = l1.begin();
+    ++i;
+    std::vector<int>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..edfcdac
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    {
+        std::vector<int> l1(a1, a1+3);
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<int>(a1+1, a1+3));
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<int>(a1+2, a1+3));
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..58e397f
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::vector<int> d(10, 1);
+    std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..59fb546
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class Iter> 
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+                                        forward_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 308> > v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+                                        forward_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 0000000..6262f75
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly> v(100);
+        std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == MoveOnly());
+        assert(v[j] == MoveOnly(3));
+        for (++j; j < 101; ++j)
+            assert(v[j] == MoveOnly());
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == MoveOnly());
+        assert(v[j] == MoveOnly(3));
+        for (++j; j < 101; ++j)
+            assert(v[j] == MoveOnly());
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..1312caf
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..2d6ee2c
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/insert_iter_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..22197e5
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int> c;
+        c.push_back(0);
+        assert(c.size() == 1);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(1);
+        assert(c.size() == 2);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(2);
+        assert(c.size() == 3);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(3);
+        assert(c.size() == 4);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(4);
+        assert(c.size() == 5);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+    }
+    {
+        std::vector<int, stack_allocator<int, 15> > c;
+        c.push_back(0);
+        assert(c.size() == 1);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(1);
+        assert(c.size() == 2);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(2);
+        assert(c.size() == 3);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(3);
+        assert(c.size() == 4);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(4);
+        assert(c.size() == 5);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+    }
+}
diff --git a/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..69b61e5
--- /dev/null
+++ b/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::vector<MoveOnly> c;
+        c.push_back(MoveOnly(0));
+        assert(c.size() == 1);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(1));
+        assert(c.size() == 2);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(2));
+        assert(c.size() == 3);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(3));
+        assert(c.size() == 4);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(4));
+        assert(c.size() == 5);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+        c.push_back(MoveOnly(0));
+        assert(c.size() == 1);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(1));
+        assert(c.size() == 2);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(2));
+        assert(c.size() == 3);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(3));
+        assert(c.size() == 4);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(4));
+        assert(c.size() == 5);
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+    }
+#endif
+}
diff --git a/test/containers/sequences/vector/vector.special/swap.pass.cpp b/test/containers/sequences/vector/vector.special/swap.pass.cpp
new file mode 100644
index 0000000..b1d489c
--- /dev/null
+++ b/test/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+//   void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+
+#include <vector>
+#include <cassert>
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1);
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1);
+        std::vector<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+    }
+}
diff --git a/test/containers/sequences/vector/version.pass.cpp b/test/containers/sequences/vector/version.pass.cpp
new file mode 100644
index 0000000..3700337
--- /dev/null
+++ b/test/containers/sequences/vector/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/stack_allocator.h b/test/containers/stack_allocator.h
new file mode 100644
index 0000000..4d3426b
--- /dev/null
+++ b/test/containers/stack_allocator.h
@@ -0,0 +1,52 @@
+#ifndef STACK_ALLOCATOR_H
+#define STACK_ALLOCATOR_H
+
+#include <cstddef>
+#include <new>
+
+template <class T, std::size_t N>
+class stack_allocator
+{
+    char buf_[sizeof(T)*N];
+    char* ptr_;
+public:
+    typedef T                 value_type;
+    typedef value_type*       pointer;
+    typedef const value_type* const_pointer;
+    typedef value_type&       reference;
+    typedef const value_type& const_reference;
+    typedef std::size_t       size_type;
+    typedef std::ptrdiff_t    difference_type;
+
+    template <class U> struct rebind {typedef stack_allocator<U, N> other;};
+
+    stack_allocator() : ptr_(buf_) {}
+
+private:
+    stack_allocator(const stack_allocator&);// = delete;
+    stack_allocator& operator=(const stack_allocator&);// = delete;
+
+public:
+    pointer allocate(size_type n, const void* = 0)
+    {
+        if (n > N - (ptr_ - buf_) / sizeof(value_type))
+            throw std::bad_alloc();
+        pointer r = (T*)ptr_;
+        ptr_ += n * sizeof(T);
+        return r;
+    }
+    void deallocate(pointer p, size_type n)
+    {
+        if ((char*)(p + n) == ptr_)
+            ptr_ = (char*)p;
+    }
+
+    size_type max_size() const {return N;}
+};
+
+template <class T, std::size_t N>
+inline
+void
+swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {}
+
+#endif
diff --git a/test/containers/test_allocator.h b/test/containers/test_allocator.h
new file mode 100644
index 0000000..898c090
--- /dev/null
+++ b/test/containers/test_allocator.h
@@ -0,0 +1,112 @@
+#ifndef TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+class test_alloc_base
+{
+protected:
+    static int count;
+public:
+    static int throw_after;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(-1) {}
+    explicit test_allocator(int i) throw() : data_(i) {}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {}
+    ~test_allocator() throw() {data_ = 0;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            if (count >= throw_after)
+                throw std::bad_alloc();
+            ++count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+#ifdef _LIBCPP_MOVE
+    void construct(pointer p, T&& val)
+        {::new(p) T(std::move(val));}
+#endif
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+template <class T>
+class other_allocator
+{
+    int data_;
+
+    template <class U> friend class other_allocator;
+
+public:
+    typedef T value_type;
+
+    other_allocator() : data_(-1) {}
+    explicit other_allocator(int i) : data_(i) {}
+    template <class U> other_allocator(const other_allocator<U>& a)
+        : data_(a.data_) {}
+    T* allocate(std::size_t n)
+        {return (T*)std::malloc(n * sizeof(T));}
+    void deallocate(T* p, std::size_t n)
+        {std::free(p);}
+
+    other_allocator select_on_container_copy_construction() const
+        {return other_allocator(-2);}
+
+    friend bool operator==(const other_allocator& x, const other_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const other_allocator& x, const other_allocator& y)
+        {return !(x == y);}
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_move_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    std::size_t max_size() const
+        {return UINT_MAX / sizeof(T);}
+#endif
+
+};
+
+#endif
diff --git a/test/containers/test_compare.h b/test/containers/test_compare.h
new file mode 100644
index 0000000..7153a4c
--- /dev/null
+++ b/test/containers/test_compare.h
@@ -0,0 +1,27 @@
+#ifndef TEST_COMPARE_H
+#define TEST_COMPARE_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+template <class C>
+class test_compare
+    : private C
+{
+    int data_;
+public:
+    explicit test_compare(int data = 0) : data_(data) {}
+
+    typename C::result_type
+    operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
+               typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
+        {return C::operator()(x, y);}
+
+    bool operator==(const test_compare& c) const
+        {return data_ == c.data_;}
+};
+
+#endif
diff --git a/test/containers/test_hash.h b/test/containers/test_hash.h
new file mode 100644
index 0000000..7bf8cbb
--- /dev/null
+++ b/test/containers/test_hash.h
@@ -0,0 +1,23 @@
+#ifndef TEST_HASH_H
+#define TEST_HASH_H
+
+#include <cstddef>
+#include <type_traits>
+
+template <class C>
+class test_hash
+    : private C
+{
+    int data_;
+public:
+    explicit test_hash(int data = 0) : data_(data) {}
+
+    std::size_t
+    operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
+        {return C::operator()(x);}
+
+    bool operator==(const test_hash& c) const
+        {return data_ == c.data_;}
+};
+
+#endif
diff --git a/test/containers/unord/next_prime.pass.cpp b/test/containers/unord/next_prime.pass.cpp
new file mode 100644
index 0000000..0275944
--- /dev/null
+++ b/test/containers/unord/next_prime.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+    switch (n)
+    {
+    case 0:
+    case 1:
+        return false;
+    }
+    for (size_t i = 2; i*i <= n; ++i)
+    {
+        if (n % i == 0)
+            return false;
+    }
+    return true;
+}
+
+int main()
+{
+    assert(std::__next_prime(0) == 0);
+    for (std::size_t n = 1; n <= 100000; ++n)
+    {
+        std::size_t p = std::__next_prime(n);
+        assert(p >= n);
+        for (std::size_t i = n; i < p; ++i)
+            assert(!is_prime(i));
+        assert(is_prime(p));
+    }
+}
diff --git a/test/containers/unord/unord.map/bucket.pass.cpp b/test/containers/unord/unord.map/bucket.pass.cpp
new file mode 100644
index 0000000..1ee61df
--- /dev/null
+++ b/test/containers/unord/unord.map/bucket.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket(const key_type& __k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+}
diff --git a/test/containers/unord/unord.map/bucket_count.pass.cpp b/test/containers/unord/unord.map/bucket_count.pass.cpp
new file mode 100644
index 0000000..d4f8ace
--- /dev/null
+++ b/test/containers/unord/unord.map/bucket_count.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+}
diff --git a/test/containers/unord/unord.map/bucket_size.pass.cpp b/test/containers/unord/unord.map/bucket_size.pass.cpp
new file mode 100644
index 0000000..6d4c4bf
--- /dev/null
+++ b/test/containers/unord/unord.map/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/count.pass.cpp b/test/containers/unord/unord.map/count.pass.cpp
new file mode 100644
index 0000000..5aa3d47
--- /dev/null
+++ b/test/containers/unord/unord.map/count.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(5) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/eq.pass.cpp b/test/containers/unord/unord.map/eq.pass.cpp
new file mode 100644
index 0000000..0585f69
--- /dev/null
+++ b/test/containers/unord/unord.map/eq.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+}
diff --git a/test/containers/unord/unord.map/equal_range_const.pass.cpp b/test/containers/unord/unord.map/equal_range_const.pass.cpp
new file mode 100644
index 0000000..ff3ec8c
--- /dev/null
+++ b/test/containers/unord/unord.map/equal_range_const.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/equal_range_non_const.pass.cpp b/test/containers/unord/unord.map/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..540f9b5
--- /dev/null
+++ b/test/containers/unord/unord.map/equal_range_non_const.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/find_const.pass.cpp b/test/containers/unord/unord.map/find_const.pass.cpp
new file mode 100644
index 0000000..4a13e81
--- /dev/null
+++ b/test/containers/unord/unord.map/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.map/find_non_const.pass.cpp b/test/containers/unord/unord.map/find_non_const.pass.cpp
new file mode 100644
index 0000000..ad3e697
--- /dev/null
+++ b/test/containers/unord/unord.map/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.map/iterators.pass.cpp b/test/containers/unord/unord.map/iterators.pass.cpp
new file mode 100644
index 0000000..160fdce
--- /dev/null
+++ b/test/containers/unord/unord.map/iterators.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.map/load_factor.pass.cpp b/test/containers/unord/unord.map/load_factor.pass.cpp
new file mode 100644
index 0000000..c097ef7
--- /dev/null
+++ b/test/containers/unord/unord.map/load_factor.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.load_factor() == (float)c.size() / c.bucket_count());
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/local_iterators.pass.cpp b/test/containers/unord/unord.map/local_iterators.pass.cpp
new file mode 100644
index 0000000..5b6ba29
--- /dev/null
+++ b/test/containers/unord/unord.map/local_iterators.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+}
diff --git a/test/containers/unord/unord.map/max_bucket_count.pass.cpp b/test/containers/unord/unord.map/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..72f8a3a
--- /dev/null
+++ b/test/containers/unord/unord.map/max_bucket_count.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/max_load_factor.pass.cpp b/test/containers/unord/unord.map/max_load_factor.pass.cpp
new file mode 100644
index 0000000..46b9d13
--- /dev/null
+++ b/test/containers/unord/unord.map/max_load_factor.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+}
diff --git a/test/containers/unord/unord.map/max_size.pass.cpp b/test/containers/unord/unord.map/max_size.pass.cpp
new file mode 100644
index 0000000..e332d86
--- /dev/null
+++ b/test/containers/unord/unord.map/max_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+
+int main()
+{
+    {
+        std::unordered_map<int, int> u;
+        assert(u.max_size() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/rehash.pass.cpp b/test/containers/unord/unord.map/rehash.pass.cpp
new file mode 100644
index 0000000..e6e71a2
--- /dev/null
+++ b/test/containers/unord/unord.map/rehash.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+void test(const std::unordered_map<int, std::string>& c)
+{
+    assert(c.size() == 4);
+    assert(c.at(1) == "one");
+    assert(c.at(2) == "two");
+    assert(c.at(3) == "three");
+    assert(c.at(4) == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.map/reserve.pass.cpp b/test/containers/unord/unord.map/reserve.pass.cpp
new file mode 100644
index 0000000..8aab778
--- /dev/null
+++ b/test/containers/unord/unord.map/reserve.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void reserve(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+void test(const std::unordered_map<int, std::string>& c)
+{
+    assert(c.size() == 4);
+    assert(c.at(1) == "one");
+    assert(c.at(2) == "two");
+    assert(c.at(3) == "three");
+    assert(c.at(4) == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() == 17);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.map/swap_member.pass.cpp b/test/containers/unord/unord.map/swap_member.pass.cpp
new file mode 100644
index 0000000..ddea2d4
--- /dev/null
+++ b/test/containers/unord/unord.map/swap_member.pass.cpp
@@ -0,0 +1,389 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/types.pass.cpp b/test/containers/unord/unord.map/types.pass.cpp
new file mode 100644
index 0000000..3a09c49
--- /dev/null
+++ b/test/containers/unord/unord.map/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+// {
+// public:
+//     // types
+//     typedef Key                                                        key_type;
+//     typedef T                                                          mapped_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef pair<const key_type, mapped_type>                          value_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::unordered_map<char, short> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..513229d
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// explicit unordered_map(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..9f44df3
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..f18f654
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..1f4561c
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c0.size() == 0);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c0.size() == 0);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..09c9ea5
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (other_allocator<std::pair<const int, std::string> >(-2)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..db49b11
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/copy_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(5)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
new file mode 100644
index 0000000..94d94d3
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
new file mode 100644
index 0000000..e3cc186
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..7cdb0e8
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..5e6dea4
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..add94c5
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..f237de1
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
new file mode 100644
index 0000000..aee0849
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..044f1f0
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
new file mode 100644
index 0000000..8487784
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..ee81501
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..1478f33
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..daea849
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..2e96436
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
new file mode 100644
index 0000000..f016fc2
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
new file mode 100644
index 0000000..3bf62b4
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..fe808d8
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..f7f14d7
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..0bc8796
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp
new file mode 100644
index 0000000..0996474
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type&       at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c.at(1) = "ONE";
+        assert(c.at(1) == "ONE");
+        try
+        {
+            c.at(11) = "eleven";
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        try
+        {
+            c.at(11);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+}
diff --git a/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp
new file mode 100644
index 0000000..b902e1f
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<MoveOnly, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..f45300c
--- /dev/null
+++ b/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
@@ -0,0 +1,389 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "fourty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..3becce2
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..1560d18
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace(3);
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == Emplaceable(5, 6));
+
+        r = c.emplace(5, 6, 7);
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == Emplaceable(6, 7));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..37ec8ff
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, 3);
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(e, std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace_hint(e, 5, 6, 7);
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..e7ed2e9
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..bad42c5
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
new file mode 100644
index 0000000..ec86454
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 1);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(k == j);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(k == c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..a6eda41
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..850520c
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..5354c24
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(const_iterator p, P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(3, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(4, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
new file mode 100644
index 0000000..6e8ba04
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
new file mode 100644
index 0000000..826985a
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+}
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..59b3a4a
--- /dev/null
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == 4);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.map/version.pass.cpp b/test/containers/unord/unord.map/version.pass.cpp
new file mode 100644
index 0000000..2837544
--- /dev/null
+++ b/test/containers/unord/unord.map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/containers/unord/unord.multimap/bucket.pass.cpp b/test/containers/unord/unord.multimap/bucket.pass.cpp
new file mode 100644
index 0000000..1afa2d9
--- /dev/null
+++ b/test/containers/unord/unord.multimap/bucket.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/bucket_count.pass.cpp b/test/containers/unord/unord.multimap/bucket_count.pass.cpp
new file mode 100644
index 0000000..6219455
--- /dev/null
+++ b/test/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/bucket_size.pass.cpp b/test/containers/unord/unord.multimap/bucket_size.pass.cpp
new file mode 100644
index 0000000..aa87831
--- /dev/null
+++ b/test/containers/unord/unord.multimap/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/count.pass.cpp b/test/containers/unord/unord.multimap/count.pass.cpp
new file mode 100644
index 0000000..955f809
--- /dev/null
+++ b/test/containers/unord/unord.multimap/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/eq.pass.cpp b/test/containers/unord/unord.multimap/eq.pass.cpp
new file mode 100644
index 0000000..9224fe7
--- /dev/null
+++ b/test/containers/unord/unord.multimap/eq.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/equal_range_const.pass.cpp b/test/containers/unord/unord.multimap/equal_range_const.pass.cpp
new file mode 100644
index 0000000..2c9a19b
--- /dev/null
+++ b/test/containers/unord/unord.multimap/equal_range_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+}
diff --git a/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..7866d86
--- /dev/null
+++ b/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+}
diff --git a/test/containers/unord/unord.multimap/find_const.pass.cpp b/test/containers/unord/unord.multimap/find_const.pass.cpp
new file mode 100644
index 0000000..2cd7a2d
--- /dev/null
+++ b/test/containers/unord/unord.multimap/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/find_non_const.pass.cpp b/test/containers/unord/unord.multimap/find_non_const.pass.cpp
new file mode 100644
index 0000000..47b0fa1
--- /dev/null
+++ b/test/containers/unord/unord.multimap/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/iterators.fail.cpp b/test/containers/unord/unord.multimap/iterators.fail.cpp
new file mode 100644
index 0000000..46ec007
--- /dev/null
+++ b/test/containers/unord/unord.multimap/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        i->second = "ONE";
+        assert(i->second == "ONE");
+        i->first = 2;
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/iterators.pass.cpp b/test/containers/unord/unord.multimap/iterators.pass.cpp
new file mode 100644
index 0000000..b6c5ed4
--- /dev/null
+++ b/test/containers/unord/unord.multimap/iterators.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        i->second = "ONE";
+        assert(i->second == "ONE");
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/load_factor.pass.cpp b/test/containers/unord/unord.multimap/load_factor.pass.cpp
new file mode 100644
index 0000000..30e8d56
--- /dev/null
+++ b/test/containers/unord/unord.multimap/load_factor.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.load_factor() == (float)c.size() / c.bucket_count());
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/local_iterators.fail.cpp b/test/containers/unord/unord.multimap/local_iterators.fail.cpp
new file mode 100644
index 0000000..48d2f83
--- /dev/null
+++ b/test/containers/unord/unord.multimap/local_iterators.fail.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        i->first = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/local_iterators.pass.cpp b/test/containers/unord/unord.multimap/local_iterators.pass.cpp
new file mode 100644
index 0000000..6916263
--- /dev/null
+++ b/test/containers/unord/unord.multimap/local_iterators.pass.cpp
@@ -0,0 +1,285 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..61cfbf3
--- /dev/null
+++ b/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/containers/unord/unord.multimap/max_load_factor.pass.cpp
new file mode 100644
index 0000000..1fad1c5
--- /dev/null
+++ b/test/containers/unord/unord.multimap/max_load_factor.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/max_size.pass.cpp b/test/containers/unord/unord.multimap/max_size.pass.cpp
new file mode 100644
index 0000000..7227a75
--- /dev/null
+++ b/test/containers/unord/unord.multimap/max_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+
+int main()
+{
+    {
+        std::unordered_multimap<int, int> u;
+        assert(u.max_size() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/rehash.pass.cpp b/test/containers/unord/unord.multimap/rehash.pass.cpp
new file mode 100644
index 0000000..b3126af
--- /dev/null
+++ b/test/containers/unord/unord.multimap/rehash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+void test(const std::unordered_multimap<int, std::string>& c)
+{
+    typedef std::unordered_multimap<int, std::string> C;
+    assert(c.size() == 6);
+    typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+    Eq eq = c.equal_range(1);
+    assert(std::distance(eq.first, eq.second) == 2);
+    C::const_iterator i = eq.first;
+    assert(i->first == 1);
+    assert(i->second == "one");
+    ++i;
+    assert(i->first == 1);
+    assert(i->second == "four");
+    eq = c.equal_range(2);
+    assert(std::distance(eq.first, eq.second) == 2);
+    i = eq.first;
+    assert(i->first == 2);
+    assert(i->second == "two");
+    ++i;
+    assert(i->first == 2);
+    assert(i->second == "four");
+
+    eq = c.equal_range(3);
+    assert(std::distance(eq.first, eq.second) == 1);
+    i = eq.first;
+    assert(i->first == 3);
+    assert(i->second == "three");
+    eq = c.equal_range(4);
+    assert(std::distance(eq.first, eq.second) == 1);
+    i = eq.first;
+    assert(i->first == 4);
+    assert(i->second == "four");
+    assert(std::distance(c.begin(), c.end()) == c.size());
+    assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    assert(c.load_factor() == (float)c.size()/c.bucket_count());
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/reserve.pass.cpp b/test/containers/unord/unord.multimap/reserve.pass.cpp
new file mode 100644
index 0000000..9d38aa9
--- /dev/null
+++ b/test/containers/unord/unord.multimap/reserve.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+void test(const std::unordered_multimap<int, std::string>& c)
+{
+    assert(c.size() == 6);
+    assert(c.find(1)->second == "one");
+    assert(next(c.find(1))->second == "four");
+    assert(c.find(2)->second == "two");
+    assert(next(c.find(2))->second == "four");
+    assert(c.find(3)->second == "three");
+    assert(c.find(4)->second == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() == 17);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/swap_member.pass.cpp b/test/containers/unord/unord.multimap/swap_member.pass.cpp
new file mode 100644
index 0000000..3d259f6
--- /dev/null
+++ b/test/containers/unord/unord.multimap/swap_member.pass.cpp
@@ -0,0 +1,397 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/types.pass.cpp b/test/containers/unord/unord.multimap/types.pass.cpp
new file mode 100644
index 0000000..d9cb9c5
--- /dev/null
+++ b/test/containers/unord/unord.multimap/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+// {
+// public:
+//     // types
+//     typedef Key                                                        key_type;
+//     typedef T                                                          mapped_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef pair<const key_type, mapped_type>                          value_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<char, short> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..e5079b6
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// explicit unordered_multimap(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..902cff0
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..466ae79
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..4b4a50a
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
@@ -0,0 +1,225 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..a75ccc0
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (other_allocator<std::pair<const int, std::string> >(-2)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..55d0d0d
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(5)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
new file mode 100644
index 0000000..e822762
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
new file mode 100644
index 0000000..6f3f5a2
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..9056c6c
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..30ab6ab
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..51c34db
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..be48046
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
new file mode 100644
index 0000000..865f2b0
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..a3f2573
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
+
+#include <iostream>
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
new file mode 100644
index 0000000..44ab153
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..7c431e7
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..d978208
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..d9fc97e
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..63d2347
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
new file mode 100644
index 0000000..4d7ec6d
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
new file mode 100644
index 0000000..0b8a6ad
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..4fd0cc6
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..d64dfdf
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..05e3700
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..813c95f
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..59de8a9
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+//     iterator emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace(3);
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace(5, 6, 7);
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..297750a
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, 3);
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(e, std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+        assert(r == next(c.begin()));
+
+        r = c.emplace_hint(r, 3, 6, 7);
+        assert(c.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(6, 7));
+        assert(r == next(c.begin()));
+        r = c.begin();
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+        r = next(r, 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..5bb2d00
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+
+        assert(c.size() == 5);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..3c20fb7
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
new file mode 100644
index 0000000..f1db7fd
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..39edf6f
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..6148941
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(e, P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..7adf708
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(const_iterator p, P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(e, P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
new file mode 100644
index 0000000..0753868
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
new file mode 100644
index 0000000..61b6a1a
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..87b81ec
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..63c6e30
--- /dev/null
+++ b/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
@@ -0,0 +1,397 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "fourty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "fourty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/bucket.pass.cpp b/test/containers/unord/unord.multiset/bucket.pass.cpp
new file mode 100644
index 0000000..0c96045
--- /dev/null
+++ b/test/containers/unord/unord.multiset/bucket.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket(const key_type& __k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/containers/unord/unord.multiset/bucket_count.pass.cpp
new file mode 100644
index 0000000..62dc7a3
--- /dev/null
+++ b/test/containers/unord/unord.multiset/bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/bucket_size.pass.cpp b/test/containers/unord/unord.multiset/bucket_size.pass.cpp
new file mode 100644
index 0000000..86399e8
--- /dev/null
+++ b/test/containers/unord/unord.multiset/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_size(size_type n) const
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/clear.pass.cpp b/test/containers/unord/unord.multiset/clear.pass.cpp
new file mode 100644
index 0000000..1fe28cd
--- /dev/null
+++ b/test/containers/unord/unord.multiset/clear.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/count.pass.cpp b/test/containers/unord/unord.multiset/count.pass.cpp
new file mode 100644
index 0000000..eebc6ee
--- /dev/null
+++ b/test/containers/unord/unord.multiset/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/emplace.pass.cpp b/test/containers/unord/unord.multiset/emplace.pass.cpp
new file mode 100644
index 0000000..2b693f4
--- /dev/null
+++ b/test/containers/unord/unord.multiset/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+//     iterator emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/emplace_hint.pass.cpp b/test/containers/unord/unord.multiset/emplace_hint.pass.cpp
new file mode 100644
index 0000000..28c40c5
--- /dev/null
+++ b/test/containers/unord/unord.multiset/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(e, Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/eq.pass.cpp b/test/containers/unord/unord.multiset/eq.pass.cpp
new file mode 100644
index 0000000..3fcf6bd
--- /dev/null
+++ b/test/containers/unord/unord.multiset/eq.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+//            const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+//            const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+}
diff --git a/test/containers/unord/unord.multiset/equal_range_const.pass.cpp b/test/containers/unord/unord.multiset/equal_range_const.pass.cpp
new file mode 100644
index 0000000..f5189c3
--- /dev/null
+++ b/test/containers/unord/unord.multiset/equal_range_const.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..c2d600d
--- /dev/null
+++ b/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..631d4c6
--- /dev/null
+++ b/test/containers/unord/unord.multiset/erase_const_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 5);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/erase_key.pass.cpp b/test/containers/unord/unord.multiset/erase_key.pass.cpp
new file mode 100644
index 0000000..3613e44
--- /dev/null
+++ b/test/containers/unord/unord.multiset/erase_key.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/erase_range.pass.cpp b/test/containers/unord/unord.multiset/erase_range.pass.cpp
new file mode 100644
index 0000000..48899fb
--- /dev/null
+++ b/test/containers/unord/unord.multiset/erase_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.multiset/find_const.pass.cpp b/test/containers/unord/unord.multiset/find_const.pass.cpp
new file mode 100644
index 0000000..f358aed
--- /dev/null
+++ b/test/containers/unord/unord.multiset/find_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.multiset/find_non_const.pass.cpp b/test/containers/unord/unord.multiset/find_non_const.pass.cpp
new file mode 100644
index 0000000..dd9aed3
--- /dev/null
+++ b/test/containers/unord/unord.multiset/find_non_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..f6f0bd0
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..41d001e
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_hint_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..4622d7b
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(e, P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(e, P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/insert_init.pass.cpp b/test/containers/unord/unord.multiset/insert_init.pass.cpp
new file mode 100644
index 0000000..4e1f954
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_init.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/insert_range.pass.cpp b/test/containers/unord/unord.multiset/insert_range.pass.cpp
new file mode 100644
index 0000000..899ea2e
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..5a1c51e
--- /dev/null
+++ b/test/containers/unord/unord.multiset/insert_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/iterators.fail.cpp b/test/containers/unord/unord.multiset/iterators.fail.cpp
new file mode 100644
index 0000000..90d3958
--- /dev/null
+++ b/test/containers/unord/unord.multiset/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        assert(*i == 1);
+        *i = 2;
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multiset/iterators.pass.cpp b/test/containers/unord/unord.multiset/iterators.pass.cpp
new file mode 100644
index 0000000..15cedf6
--- /dev/null
+++ b/test/containers/unord/unord.multiset/iterators.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.multiset/load_factor.pass.cpp b/test/containers/unord/unord.multiset/load_factor.pass.cpp
new file mode 100644
index 0000000..1f790e9
--- /dev/null
+++ b/test/containers/unord/unord.multiset/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.load_factor() == (float)c.size() / c.bucket_count());
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/local_iterators.fail.cpp b/test/containers/unord/unord.multiset/local_iterators.fail.cpp
new file mode 100644
index 0000000..0aa8048
--- /dev/null
+++ b/test/containers/unord/unord.multiset/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        *i = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/local_iterators.pass.cpp b/test/containers/unord/unord.multiset/local_iterators.pass.cpp
new file mode 100644
index 0000000..60ee79b
--- /dev/null
+++ b/test/containers/unord/unord.multiset/local_iterators.pass.cpp
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..f2b47bd
--- /dev/null
+++ b/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/containers/unord/unord.multiset/max_load_factor.pass.cpp
new file mode 100644
index 0000000..2cd3c8c
--- /dev/null
+++ b/test/containers/unord/unord.multiset/max_load_factor.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/max_size.pass.cpp b/test/containers/unord/unord.multiset/max_size.pass.cpp
new file mode 100644
index 0000000..771ded8
--- /dev/null
+++ b/test/containers/unord/unord.multiset/max_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+
+int main()
+{
+    {
+        std::unordered_multiset<int> u;
+        assert(u.max_size() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/rehash.pass.cpp b/test/containers/unord/unord.multiset/rehash.pass.cpp
new file mode 100644
index 0000000..b540ffb
--- /dev/null
+++ b/test/containers/unord/unord.multiset/rehash.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+void test(const std::unordered_multiset<int>& c)
+{
+    assert(c.size() == 6);
+    assert(c.count(1) == 2);
+    assert(c.count(2) == 2);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/reserve.pass.cpp b/test/containers/unord/unord.multiset/reserve.pass.cpp
new file mode 100644
index 0000000..aceea41
--- /dev/null
+++ b/test/containers/unord/unord.multiset/reserve.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+void test(const std::unordered_multiset<int>& c)
+{
+    assert(c.size() == 6);
+    assert(c.count(1) == 2);
+    assert(c.count(2) == 2);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() == 17);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/swap_member.pass.cpp b/test/containers/unord/unord.multiset/swap_member.pass.cpp
new file mode 100644
index 0000000..ad17bf5
--- /dev/null
+++ b/test/containers/unord/unord.multiset/swap_member.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& __u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/types.pass.cpp b/test/containers/unord/unord.multiset/types.pass.cpp
new file mode 100644
index 0000000..c602778
--- /dev/null
+++ b/test/containers/unord/unord.multiset/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+// {
+// public:
+//     // types
+//     typedef Value                                                      value_type;
+//     typedef value_type                                                 key_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<short> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..aaa3a70
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(test_allocator<NotConstructible>(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..09e4f35
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,133 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..43e06b3
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..01c88ae
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
@@ -0,0 +1,172 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..eaf3a90
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == other_allocator<int>(-2));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..9aef5a4
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c(c0, test_allocator<int>(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(5));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
new file mode 100644
index 0000000..30c4bd5
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
new file mode 100644
index 0000000..47fe20d
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..0053b9c
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..9d7b707
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..1243c8d
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..1b9767d
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
new file mode 100644
index 0000000..fc9ce49
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..05c1272
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
new file mode 100644
index 0000000..effe6bc
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..5f12dd8
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..3e3ad3f
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..e116583
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..e10c121
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
new file mode 100644
index 0000000..d43e2de
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
new file mode 100644
index 0000000..b70a9f4
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..9bc787b
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..7aecec3
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..f7137d7
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..e7de76e
--- /dev/null
+++ b/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/bucket.pass.cpp b/test/containers/unord/unord.set/bucket.pass.cpp
new file mode 100644
index 0000000..ed74227
--- /dev/null
+++ b/test/containers/unord/unord.set/bucket.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket(const key_type& __k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+}
diff --git a/test/containers/unord/unord.set/bucket_count.pass.cpp b/test/containers/unord/unord.set/bucket_count.pass.cpp
new file mode 100644
index 0000000..ff0ad30
--- /dev/null
+++ b/test/containers/unord/unord.set/bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+}
diff --git a/test/containers/unord/unord.set/bucket_size.pass.cpp b/test/containers/unord/unord.set/bucket_size.pass.cpp
new file mode 100644
index 0000000..2042b84
--- /dev/null
+++ b/test/containers/unord/unord.set/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_size(size_type n) const
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/clear.pass.cpp b/test/containers/unord/unord.set/clear.pass.cpp
new file mode 100644
index 0000000..bdadcce
--- /dev/null
+++ b/test/containers/unord/unord.set/clear.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/count.pass.cpp b/test/containers/unord/unord.set/count.pass.cpp
new file mode 100644
index 0000000..bf19c08
--- /dev/null
+++ b/test/containers/unord/unord.set/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 1);
+        assert(c.count(5) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/emplace.pass.cpp b/test/containers/unord/unord.set/emplace.pass.cpp
new file mode 100644
index 0000000..f6d769b
--- /dev/null
+++ b/test/containers/unord/unord.set/emplace.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+//     pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<Emplaceable> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r.first == Emplaceable());
+        assert(r.second);
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(r.second);
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(!r.second);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/emplace_hint.pass.cpp b/test/containers/unord/unord.set/emplace_hint.pass.cpp
new file mode 100644
index 0000000..745093f
--- /dev/null
+++ b/test/containers/unord/unord.set/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(e, Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/eq.pass.cpp b/test/containers/unord/unord.set/eq.pass.cpp
new file mode 100644
index 0000000..134af70
--- /dev/null
+++ b/test/containers/unord/unord.set/eq.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
+//            const unordered_set<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
+//            const unordered_set<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+}
diff --git a/test/containers/unord/unord.set/equal_range_const.pass.cpp b/test/containers/unord/unord.set/equal_range_const.pass.cpp
new file mode 100644
index 0000000..2ab279a
--- /dev/null
+++ b/test/containers/unord/unord.set/equal_range_const.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+}
diff --git a/test/containers/unord/unord.set/equal_range_non_const.pass.cpp b/test/containers/unord/unord.set/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..08db57d
--- /dev/null
+++ b/test/containers/unord/unord.set/equal_range_non_const.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+}
diff --git a/test/containers/unord/unord.set/erase_const_iter.pass.cpp b/test/containers/unord/unord.set/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..9e57f43
--- /dev/null
+++ b/test/containers/unord/unord.set/erase_const_iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/erase_key.pass.cpp b/test/containers/unord/unord.set/erase_key.pass.cpp
new file mode 100644
index 0000000..96c79a6
--- /dev/null
+++ b/test/containers/unord/unord.set/erase_key.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/erase_range.pass.cpp b/test/containers/unord/unord.set/erase_range.pass.cpp
new file mode 100644
index 0000000..97315d2
--- /dev/null
+++ b/test/containers/unord/unord.set/erase_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+}
diff --git a/test/containers/unord/unord.set/find_const.pass.cpp b/test/containers/unord/unord.set/find_const.pass.cpp
new file mode 100644
index 0000000..abc79a9
--- /dev/null
+++ b/test/containers/unord/unord.set/find_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.set/find_non_const.pass.cpp b/test/containers/unord/unord.set/find_non_const.pass.cpp
new file mode 100644
index 0000000..5cfefa9
--- /dev/null
+++ b/test/containers/unord/unord.set/find_non_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+}
diff --git a/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..be02bff
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+}
diff --git a/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..019df70
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_hint_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+}
diff --git a/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..c16d421
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(e, P(4));
+        assert(c.size() == 2);
+        assert(*r == 4);
+
+        r = c.insert(e, P(5));
+        assert(c.size() == 3);
+        assert(*r == 5);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/insert_init.pass.cpp b/test/containers/unord/unord.set/insert_init.pass.cpp
new file mode 100644
index 0000000..478699e
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_init.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/insert_range.pass.cpp b/test/containers/unord/unord.set/insert_range.pass.cpp
new file mode 100644
index 0000000..421143f
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../iterators.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/insert_rvalue.pass.cpp b/test/containers/unord/unord.set/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..9b7e91e
--- /dev/null
+++ b/test/containers/unord/unord.set/insert_rvalue.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(r.second);
+
+        r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(!r.second);
+
+        r = c.insert(P(4));
+        assert(c.size() == 2);
+        assert(*r.first == 4);
+        assert(r.second);
+
+        r = c.insert(P(5));
+        assert(c.size() == 3);
+        assert(*r.first == 5);
+        assert(r.second);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/iterators.fail.cpp b/test/containers/unord/unord.set/iterators.fail.cpp
new file mode 100644
index 0000000..fb3cc87
--- /dev/null
+++ b/test/containers/unord/unord.set/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        assert(*i == 1);
+        *i = 2;
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.set/iterators.pass.cpp b/test/containers/unord/unord.set/iterators.pass.cpp
new file mode 100644
index 0000000..4bfb712
--- /dev/null
+++ b/test/containers/unord/unord.set/iterators.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/test/containers/unord/unord.set/load_factor.pass.cpp b/test/containers/unord/unord.set/load_factor.pass.cpp
new file mode 100644
index 0000000..698d47f
--- /dev/null
+++ b/test/containers/unord/unord.set/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.load_factor() == (float)c.size() / c.bucket_count());
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/local_iterators.fail.cpp b/test/containers/unord/unord.set/local_iterators.fail.cpp
new file mode 100644
index 0000000..381bf09
--- /dev/null
+++ b/test/containers/unord/unord.set/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        *i = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/local_iterators.pass.cpp b/test/containers/unord/unord.set/local_iterators.pass.cpp
new file mode 100644
index 0000000..da705d7
--- /dev/null
+++ b/test/containers/unord/unord.set/local_iterators.pass.cpp
@@ -0,0 +1,204 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+}
diff --git a/test/containers/unord/unord.set/max_bucket_count.pass.cpp b/test/containers/unord/unord.set/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..4362706
--- /dev/null
+++ b/test/containers/unord/unord.set/max_bucket_count.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/max_load_factor.pass.cpp b/test/containers/unord/unord.set/max_load_factor.pass.cpp
new file mode 100644
index 0000000..93127d9
--- /dev/null
+++ b/test/containers/unord/unord.set/max_load_factor.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+}
diff --git a/test/containers/unord/unord.set/max_size.pass.cpp b/test/containers/unord/unord.set/max_size.pass.cpp
new file mode 100644
index 0000000..0d701d4
--- /dev/null
+++ b/test/containers/unord/unord.set/max_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+
+int main()
+{
+    {
+        std::unordered_set<int> u;
+        assert(u.max_size() > 0);
+    }
+}
diff --git a/test/containers/unord/unord.set/rehash.pass.cpp b/test/containers/unord/unord.set/rehash.pass.cpp
new file mode 100644
index 0000000..96f8751
--- /dev/null
+++ b/test/containers/unord/unord.set/rehash.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+void test(const std::unordered_set<int>& c)
+{
+    assert(c.size() == 4);
+    assert(c.count(1) == 1);
+    assert(c.count(2) == 1);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.set/reserve.pass.cpp b/test/containers/unord/unord.set/reserve.pass.cpp
new file mode 100644
index 0000000..b6a8e28
--- /dev/null
+++ b/test/containers/unord/unord.set/reserve.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+void test(const std::unordered_set<int>& c)
+{
+    assert(c.size() == 4);
+    assert(c.count(1) == 1);
+    assert(c.count(2) == 1);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() == 17);
+        test(c);
+    }
+}
diff --git a/test/containers/unord/unord.set/swap_member.pass.cpp b/test/containers/unord/unord.set/swap_member.pass.cpp
new file mode 100644
index 0000000..366e32d
--- /dev/null
+++ b/test/containers/unord/unord.set/swap_member.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/types.pass.cpp b/test/containers/unord/unord.set/types.pass.cpp
new file mode 100644
index 0000000..7e9eaa9
--- /dev/null
+++ b/test/containers/unord/unord.set/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+// {
+// public:
+//     // types
+//     typedef Value                                                      value_type;
+//     typedef value_type                                                 key_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::unordered_set<short> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..f35eadb
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(test_allocator<NotConstructible>(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..e0c09e0
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..5437c23
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..131225b
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..34b38c1
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == other_allocator<int>(-2));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..5ed1a10
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c(c0, test_allocator<int>(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(5));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
new file mode 100644
index 0000000..eee0ecf
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
new file mode 100644
index 0000000..10068c7
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..a516905
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..b2becd5
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..18aef8d
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..d73993e
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
new file mode 100644
index 0000000..7da9735
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..3212351
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
new file mode 100644
index 0000000..0502f80
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..05e1c6c
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..3bb8728
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..7d5cd5e
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..87eee0b
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == (float)c.size()/c.bucket_count());
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
new file mode 100644
index 0000000..e5517a7
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
new file mode 100644
index 0000000..7916060
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..9b3a7ab
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..af290dc
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..11e5a2e
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..4e87175
--- /dev/null
+++ b/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "../../../test_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+}
diff --git a/test/containers/unord/unord.set/version.pass.cpp b/test/containers/unord/unord.set/version.pass.cpp
new file mode 100644
index 0000000..620da44
--- /dev/null
+++ b/test/containers/unord/unord.set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+#include <unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/A.h b/test/depr/depr.auto.ptr/auto.ptr/A.h
new file mode 100644
index 0000000..cab46e3
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/A.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef A_H
+#define A_H
+
+#include <cassert>
+
+class A
+{
+    int id_;
+public:
+    explicit A(int id) : id_(id) {++count;}
+    A(const A& a) : id_(a.id_) {++count;}
+    ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+    int id() const {return id_;}
+
+    static int count;
+};
+
+int A::count = 0;
+
+#endif
diff --git a/test/depr/depr.auto.ptr/auto.ptr/AB.h b/test/depr/depr.auto.ptr/auto.ptr/AB.h
new file mode 100644
index 0000000..a78f474
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/AB.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef AB_H
+#define AB_H
+
+#include <cassert>
+
+class A
+{
+    int id_;
+public:
+    explicit A(int id) : id_(id) {++count;}
+    A(const A& a) : id_(a.id_) {++count;}
+    virtual ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+    static int count;
+};
+
+int A::count = 0;
+
+class B
+    : public A
+{
+public:
+    explicit B(int id) : A(id) {++count;}
+    B(const B& a) : A(a) {++count;}
+    virtual ~B() {--count;}
+
+    static int count;
+};
+
+int B::count = 0;
+
+#endif
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp
new file mode 100644
index 0000000..4ab223d
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    const std::auto_ptr<A> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
new file mode 100644
index 0000000..7fa8701
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    std::auto_ptr<A> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
new file mode 100644
index 0000000..337af87
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p = new B(1);
+    const std::auto_ptr<B> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
new file mode 100644
index 0000000..d2835b0
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p = new B(1);
+    std::auto_ptr<B> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
new file mode 100644
index 0000000..3964ee6
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    const std::auto_ptr<B> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(B::count == 1);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
new file mode 100644
index 0000000..67e58f4
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(B::count == 1);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
new file mode 100644
index 0000000..222e585
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    const std::auto_ptr<A> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
new file mode 100644
index 0000000..1a32122
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
new file mode 100644
index 0000000..0e02e9b
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap = p;
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::auto_ptr<A> ap;
+    assert(ap.get() == 0);
+    }
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
new file mode 100644
index 0000000..5fe45db
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::auto_ptr<A> ap;
+    assert(ap.get() == 0);
+    }
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..7063869
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr_ref<X> r) throw()
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    std::auto_ptr<A> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    std::auto_ptr<A> ap2(new A(2));
+    ap2 = apr;
+    assert(A::count == 1);
+    assert(ap2.get() == p1);
+    assert(ap1.get() == 0);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..9ca69c2
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr_ref<X> r) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    std::auto_ptr<A> ap2(apr);
+    assert(ap2.get() == p1);
+    assert(ap1.get() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
new file mode 100644
index 0000000..629cb2b
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+std::auto_ptr<B>
+source()
+{
+    return std::auto_ptr<B>(new B(1));
+}
+
+void
+test()
+{
+    std::auto_ptr<A> ap2(source());
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..bc434e3
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr_ref<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    delete p1;
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
new file mode 100644
index 0000000..48822ed
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    assert(ap->id() == 1);
+    *ap = A(3);
+    assert(ap->id() == 3);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
new file mode 100644
index 0000000..5b3323d
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    const std::auto_ptr<A> ap(p);
+    assert((*ap).id() == 1);
+    *ap = A(3);
+    assert((*ap).id() == 3);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
new file mode 100644
index 0000000..f282b1b
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X* release() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    A* p2 = ap.release();
+    assert(p2 == p);
+    assert(ap.get() == 0);
+    delete p;
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
new file mode 100644
index 0000000..49cd55a
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// void reset(X* p=0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    ap.reset();
+    assert(ap.get() == 0);
+    assert(A::count == 0);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    ap.reset(p);
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    A* p2 = new A(2);
+    ap.reset(p2);
+    assert(ap.get() == p2);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
new file mode 100644
index 0000000..79bd8f3
--- /dev/null
+++ b/test/depr/depr.auto.ptr/auto.ptr/element_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X>
+// class auto_ptr
+// { 
+// public: 
+//   typedef X element_type;
+//   ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_same<typename std::auto_ptr<T>::element_type, T>::value), "");
+}
+
+int main()
+{
+    test<int>();
+    test<double>();
+    test<void>();
+    std::auto_ptr<void> p;
+}
diff --git a/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp b/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/assert_h.pass.cpp b/test/depr/depr.c.headers/assert_h.pass.cpp
new file mode 100644
index 0000000..ed51a77
--- /dev/null
+++ b/test/depr/depr.c.headers/assert_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <assert.h>
+
+#include <assert.h>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/ciso646.pass.cpp b/test/depr/depr.c.headers/ciso646.pass.cpp
new file mode 100644
index 0000000..0512669
--- /dev/null
+++ b/test/depr/depr.c.headers/ciso646.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ciso646>
+
+#include <ciso646>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/complex.h.pass.cpp b/test/depr/depr.c.headers/complex.h.pass.cpp
new file mode 100644
index 0000000..4c9435f
--- /dev/null
+++ b/test/depr/depr.c.headers/complex.h.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex.h>
+
+
+#include <complex.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> d;
+}
diff --git a/test/depr/depr.c.headers/ctype_h.pass.cpp b/test/depr/depr.c.headers/ctype_h.pass.cpp
new file mode 100644
index 0000000..bd74bea
--- /dev/null
+++ b/test/depr/depr.c.headers/ctype_h.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctype.h>
+
+#include <ctype.h>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+    static_assert((std::is_same<decltype(isalnum(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isalpha(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isblank(0)), int>::value), "");
+    static_assert((std::is_same<decltype(iscntrl(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgraph(0)), int>::value), "");
+    static_assert((std::is_same<decltype(islower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isprint(0)), int>::value), "");
+    static_assert((std::is_same<decltype(ispunct(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isspace(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isupper(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isxdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(tolower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(toupper(0)), int>::value), "");
+
+    assert(isalnum('a'));
+    assert(isalpha('a'));
+    assert(isblank(' '));
+    assert(!iscntrl(' '));
+    assert(!isdigit('a'));
+    assert(isgraph('a'));
+    assert(islower('a'));
+    assert(isprint('a'));
+    assert(!ispunct('a'));
+    assert(!isspace('a'));
+    assert(!isupper('a'));
+    assert(isxdigit('a'));
+    assert(tolower('A') == 'a');
+    assert(toupper('a') == 'A');
+}
diff --git a/test/depr/depr.c.headers/errno_h.pass.cpp b/test/depr/depr.c.headers/errno_h.pass.cpp
new file mode 100644
index 0000000..19d251f
--- /dev/null
+++ b/test/depr/depr.c.headers/errno_h.pass.cpp
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//===-------------------------- algorithm ---------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <errno.h>
+
+#include <errno.h>
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/fenv_h.pass.cpp b/test/depr/depr.c.headers/fenv_h.pass.cpp
new file mode 100644
index 0000000..a3a4b21
--- /dev/null
+++ b/test/depr/depr.c.headers/fenv_h.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fenv.h>
+
+#include <fenv.h>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+    fenv_t fenv = {0};
+    fexcept_t fex = 0;
+    static_assert((std::is_same<decltype(feclearexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(feraiseexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fesetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(fetestexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetround()), int>::value), "");
+    static_assert((std::is_same<decltype(fesetround(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(feholdexcept(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(fesetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/test/depr/depr.c.headers/float_h.pass.cpp b/test/depr/depr.c.headers/float_h.pass.cpp
new file mode 100644
index 0000000..0d6a798
--- /dev/null
+++ b/test/depr/depr.c.headers/float_h.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test <float.h>
+
+#include <float.h>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/inttypes_h.pass.cpp b/test/depr/depr.c.headers/inttypes_h.pass.cpp
new file mode 100644
index 0000000..c5949c6
--- /dev/null
+++ b/test/depr/depr.c.headers/inttypes_h.pass.cpp
@@ -0,0 +1,929 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <inttypes.h>
+
+#include <inttypes.h>
+#include <type_traits>
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+    {
+    int8_t  i1 = 0;
+    int16_t i2 = 0;
+    int32_t i3 = 0;
+    int64_t i4 = 0;
+    }
+    {
+    uint8_t  i1 = 0;
+    uint16_t i2 = 0;
+    uint32_t i3 = 0;
+    uint64_t i4 = 0;
+    }
+    {
+    int_least8_t  i1 = 0;
+    int_least16_t i2 = 0;
+    int_least32_t i3 = 0;
+    int_least64_t i4 = 0;
+    }
+    {
+    uint_least8_t  i1 = 0;
+    uint_least16_t i2 = 0;
+    uint_least32_t i3 = 0;
+    uint_least64_t i4 = 0;
+    }
+    {
+    int_fast8_t  i1 = 0;
+    int_fast16_t i2 = 0;
+    int_fast32_t i3 = 0;
+    int_fast64_t i4 = 0;
+    }
+    {
+    uint_fast8_t  i1 = 0;
+    uint_fast16_t i2 = 0;
+    uint_fast32_t i3 = 0;
+    uint_fast64_t i4 = 0;
+    }
+    {
+    intptr_t  i1 = 0;
+    uintptr_t i2 = 0;
+    intmax_t  i3 = 0;
+    uintmax_t i4 = 0;
+    }
+    {
+    imaxdiv_t  i1 = {0};
+    }
+    intmax_t i = 0;
+    static_assert((std::is_same<decltype(imaxabs(i)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(imaxdiv(i, i)), imaxdiv_t>::value), "");
+    static_assert((std::is_same<decltype(strtoimax("", (char**)0, 0)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(strtoumax("", (char**)0, 0)), uintmax_t>::value), "");
+    static_assert((std::is_same<decltype(wcstoimax(L"", (wchar_t**)0, 0)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(wcstoumax(L"", (wchar_t**)0, 0)), uintmax_t>::value), "");
+}
diff --git a/test/depr/depr.c.headers/iso646_h.pass.cpp b/test/depr/depr.c.headers/iso646_h.pass.cpp
new file mode 100644
index 0000000..e22070d
--- /dev/null
+++ b/test/depr/depr.c.headers/iso646_h.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iso646.h>
+
+#include <iso646.h>
+
+int main()
+{
+    // Nothing to test
+}
diff --git a/test/depr/depr.c.headers/limits_h.pass.cpp b/test/depr/depr.c.headers/limits_h.pass.cpp
new file mode 100644
index 0000000..ac726b9
--- /dev/null
+++ b/test/depr/depr.c.headers/limits_h.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test limits.h
+
+#include <limits.h>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/locale_h.pass.cpp b/test/depr/depr.c.headers/locale_h.pass.cpp
new file mode 100644
index 0000000..0e30a4e
--- /dev/null
+++ b/test/depr/depr.c.headers/locale_h.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale.h>
+
+#include <locale.h>
+#include <type_traits>
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    lconv lc;
+    static_assert((std::is_same<__typeof__(setlocale(0, "")), char*>::value), "");
+    static_assert((std::is_same<__typeof__(localeconv()), lconv*>::value), "");
+}
diff --git a/test/depr/depr.c.headers/math_h.pass.cpp b/test/depr/depr.c.headers/math_h.pass.cpp
new file mode 100644
index 0000000..81e6b91
--- /dev/null
+++ b/test/depr/depr.c.headers/math_h.pass.cpp
@@ -0,0 +1,679 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <math.h>
+
+#include <math.h>
+#include <type_traits>
+#include <cassert>
+
+void test_acos()
+{
+    static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
+    assert(acos(1) == 0);
+}
+
+void test_asin()
+{
+    static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
+    assert(asin(0) == 0);
+}
+
+void test_atan()
+{
+    static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
+    assert(atan(0) == 0);
+}
+
+void test_atan2()
+{
+    static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
+    assert(atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+    static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
+    assert(ceil(0) == 0);
+}
+
+void test_cos()
+{
+    static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
+    assert(cos(0) == 1);
+}
+
+void test_cosh()
+{
+    static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
+    assert(cosh(0) == 1);
+}
+
+void test_exp()
+{
+    static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(expf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
+    assert(exp(0) == 1);
+}
+
+void test_fabs()
+{
+    static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fabsf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(fabsl(0)), long double>::value), "");
+    assert(fabs(-1) == 1);
+}
+
+void test_floor()
+{
+    static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
+    assert(floor(1) == 1);
+}
+
+void test_fmod()
+{
+    static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
+    assert(fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+    int ip;
+    static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
+    assert(frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+    int ip = 1;
+    static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
+    assert(ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+    static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(logf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
+    assert(log(1) == 0);
+}
+
+void test_log10()
+{
+    static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
+    assert(log10(1) == 0);
+}
+
+void test_modf()
+{
+    static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
+    static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
+    double i;
+    assert(modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+    static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
+    assert(pow(1,1) == 1);
+}
+
+void test_sin()
+{
+    static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
+    assert(sin(0) == 0);
+}
+
+void test_sinh()
+{
+    static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
+    assert(sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+    static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
+    assert(sqrt(4) == 2);
+}
+
+void test_tan()
+{
+    static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
+    assert(tan(0) == 0);
+}
+
+void test_tanh()
+{
+    static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
+    assert(tanh(0) == 0);
+}
+
+void test_signbit()
+{
+    static_assert((std::is_same<decltype(signbit((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(signbit((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(signbit((long double)0)), int>::value), "");
+    assert(signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+    static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
+    assert(fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+    static_assert((std::is_same<decltype(isfinite((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isfinite((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isfinite((long double)0)), int>::value), "");
+    assert(isfinite(-1.0) == true);
+}
+
+void test_isinf()
+{
+    static_assert((std::is_same<decltype(isinf((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isinf((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isinf((long double)0)), int>::value), "");
+    assert(isinf(-1.0) == false);
+}
+
+void test_isnan()
+{
+    static_assert((std::is_same<decltype(isnan((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isnan((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isnan((long double)0)), int>::value), "");
+    assert(isnan(-1.0) == false);
+}
+
+void test_isnormal()
+{
+    static_assert((std::is_same<decltype(isnormal((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isnormal((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isnormal((long double)0)), int>::value), "");
+    assert(isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+    static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), int>::value), "");
+    assert(isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), int>::value), "");
+    assert(isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+    static_assert((std::is_same<decltype(isless((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), int>::value), "");
+    assert(isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+    static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), int>::value), "");
+    assert(islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+    static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), int>::value), "");
+    assert(islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+    static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), int>::value), "");
+    assert(isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+    static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
+    assert(acosh(1) == 0);
+}
+
+void test_asinh()
+{
+    static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
+    assert(asinh(0) == 0);
+}
+
+void test_atanh()
+{
+    static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
+    assert(atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+    static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
+    assert(cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+    static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
+    assert(copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+    static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(erff(0)), float>::value), "");
+    static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
+    assert(erf(0) == 0);
+}
+
+void test_erfc()
+{
+    static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
+    assert(erfc(0) == 1);
+}
+
+void test_exp2()
+{
+    static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
+    assert(exp2(1) == 2);
+}
+
+void test_expm1()
+{
+    static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
+    assert(expm1(0) == 0);
+}
+
+void test_fdim()
+{
+    static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
+    assert(fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+    static_assert((std::is_same<decltype(fma((double)0, (double)0,  (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
+    assert(fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+    static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
+    assert(fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+    static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
+    assert(fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+    static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
+    assert(hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+    static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
+    static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
+    assert(ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+    static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
+    assert(lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+    static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
+    assert(llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+    static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
+    assert(llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+    static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
+    assert(log1p(0) == 0);
+}
+
+void test_log2()
+{
+    static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
+    assert(log2(1) == 0);
+}
+
+void test_logb()
+{
+    static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
+    assert(logb(1) == 0);
+}
+
+void test_lrint()
+{
+    static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
+    assert(lrint(1) == 1L);
+}
+
+void test_lround()
+{
+    static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
+    assert(lround(1) == 1L);
+}
+
+void test_nan()
+{
+    static_assert((std::is_same<decltype(nan("")), double>::value), "");
+    static_assert((std::is_same<decltype(nanf("")), float>::value), "");
+    static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+    static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
+    assert(nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+    static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
+    assert(nextafter(0,1) == 0x1p-1074);
+}
+
+void test_nexttoward()
+{
+    static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
+    assert(nexttoward(0, 1) == 0x1p-1074);
+}
+
+void test_remainder()
+{
+    static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
+    assert(remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+    int ip;
+    static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
+    assert(remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+    static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
+    assert(rint(1) == 1);
+}
+
+void test_round()
+{
+    static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
+    assert(round(1) == 1);
+}
+
+void test_scalbln()
+{
+    static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
+    assert(scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+    static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
+    assert(scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+    static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
+    assert(tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+    static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
+    assert(trunc(1) == 1);
+}
+
+int main()
+{
+    test_acos();
+    test_asin();
+    test_atan();
+    test_atan2();
+    test_ceil();
+    test_cos();
+    test_cosh();
+    test_exp();
+    test_fabs();
+    test_floor();
+    test_fmod();
+    test_frexp();
+    test_ldexp();
+    test_log();
+    test_log10();
+    test_modf();
+    test_pow();
+    test_sin();
+    test_sinh();
+    test_sqrt();
+    test_tan();
+    test_tanh();
+    test_signbit();
+    test_fpclassify();
+    test_isfinite();
+    test_isinf();
+    test_isnan();
+    test_isnormal();
+    test_isgreater();
+    test_isgreaterequal();
+    test_isless();
+    test_islessequal();
+    test_islessgreater();
+    test_isunordered();
+    test_acosh();
+    test_asinh();
+    test_atanh();
+    test_cbrt();
+    test_copysign();
+    test_erf();
+    test_erfc();
+    test_exp2();
+    test_expm1();
+    test_fdim();
+    test_fma();
+    test_fmax();
+    test_fmin();
+    test_hypot();
+    test_ilogb();
+    test_lgamma();
+    test_llrint();
+    test_llround();
+    test_log1p();
+    test_log2();
+    test_logb();
+    test_lrint();
+    test_lround();
+    test_nan();
+    test_nearbyint();
+    test_nextafter();
+    test_nexttoward();
+    test_remainder();
+    test_remquo();
+    test_rint();
+    test_round();
+    test_scalbln();
+    test_scalbn();
+    test_tgamma();
+    test_trunc();
+}
diff --git a/test/depr/depr.c.headers/setjmp_h.pass.cpp b/test/depr/depr.c.headers/setjmp_h.pass.cpp
new file mode 100644
index 0000000..b52ae59
--- /dev/null
+++ b/test/depr/depr.c.headers/setjmp_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <setjmp.h>
+
+#include <setjmp.h>
+#include <type_traits>
+
+int main()
+{
+    jmp_buf jb;
+    static_assert((std::is_same<__typeof__(longjmp(jb, 0)), void>::value),
+                  "std::is_same<__typeof__(longjmp(jb, 0)), void>::value");
+}
diff --git a/test/depr/depr.c.headers/signal_h.pass.cpp b/test/depr/depr.c.headers/signal_h.pass.cpp
new file mode 100644
index 0000000..86b8542
--- /dev/null
+++ b/test/depr/depr.c.headers/signal_h.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <signal.h>
+
+#include <signal.h>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+    sig_atomic_t sig;
+    typedef void (*func)(int);
+    static_assert((std::is_same<decltype(signal(0, (func)0)), func>::value), "");
+    static_assert((std::is_same<decltype(raise(0)), int>::value), "");
+}
diff --git a/test/depr/depr.c.headers/stdarg_h.pass.cpp b/test/depr/depr.c.headers/stdarg_h.pass.cpp
new file mode 100644
index 0000000..bada472
--- /dev/null
+++ b/test/depr/depr.c.headers/stdarg_h.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdarg.h>
+
+#include <stdarg.h>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#ifndef va_copy
+#error va_copy not defined
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+    va_list va;
+}
diff --git a/test/depr/depr.c.headers/stdbool_h.pass.cpp b/test/depr/depr.c.headers/stdbool_h.pass.cpp
new file mode 100644
index 0000000..b2b4647
--- /dev/null
+++ b/test/depr/depr.c.headers/stdbool_h.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdbool.h>
+
+#include <stdbool.h>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/stddef_h.pass.cpp b/test/depr/depr.c.headers/stddef_h.pass.cpp
new file mode 100644
index 0000000..3fc56bc
--- /dev/null
+++ b/test/depr/depr.c.headers/stddef_h.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stddef.h>
+
+#include <stddef.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+int main()
+{
+    static_assert(sizeof(size_t) == sizeof(void*),
+                  "sizeof(size_t) == sizeof(void*)");
+    static_assert(std::is_unsigned<size_t>::value,
+                  "std::is_unsigned<size_t>::value");
+    static_assert(std::is_integral<size_t>::value,
+                  "std::is_integral<size_t>::value");
+    static_assert(sizeof(ptrdiff_t) == sizeof(void*),
+                  "sizeof(ptrdiff_t) == sizeof(void*)");
+    static_assert(std::is_signed<ptrdiff_t>::value,
+                  "std::is_signed<ptrdiff_t>::value");
+    static_assert(std::is_integral<ptrdiff_t>::value,
+                  "std::is_integral<ptrdiff_t>::value");
+}
diff --git a/test/depr/depr.c.headers/stdint_h.pass.cpp b/test/depr/depr.c.headers/stdint_h.pass.cpp
new file mode 100644
index 0000000..c509db7
--- /dev/null
+++ b/test/depr/depr.c.headers/stdint_h.pass.cpp
@@ -0,0 +1,290 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdint.h>
+
+#include <stdint.h>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    // typedef int8_t
+    static_assert(sizeof(int8_t)*CHAR_BIT == 8,
+                 "sizeof(int8_t)*CHAR_BIT == 8");
+    static_assert(std::is_signed<int8_t>::value,
+                 "std::is_signed<int8_t>::value");
+    // typedef int16_t
+    static_assert(sizeof(int16_t)*CHAR_BIT == 16,
+                 "sizeof(int16_t)*CHAR_BIT == 16");
+    static_assert(std::is_signed<int16_t>::value,
+                 "std::is_signed<int16_t>::value");
+    // typedef int32_t
+    static_assert(sizeof(int32_t)*CHAR_BIT == 32,
+                 "sizeof(int32_t)*CHAR_BIT == 32");
+    static_assert(std::is_signed<int32_t>::value,
+                 "std::is_signed<int32_t>::value");
+    // typedef int64_t
+    static_assert(sizeof(int64_t)*CHAR_BIT == 64,
+                 "sizeof(int64_t)*CHAR_BIT == 64");
+    static_assert(std::is_signed<int64_t>::value,
+                 "std::is_signed<int64_t>::value");
+
+    // typedef uint8_t
+    static_assert(sizeof(uint8_t)*CHAR_BIT == 8,
+                 "sizeof(uint8_t)*CHAR_BIT == 8");
+    static_assert(std::is_unsigned<uint8_t>::value,
+                 "std::is_unsigned<uint8_t>::value");
+    // typedef uint16_t
+    static_assert(sizeof(uint16_t)*CHAR_BIT == 16,
+                 "sizeof(uint16_t)*CHAR_BIT == 16");
+    static_assert(std::is_unsigned<uint16_t>::value,
+                 "std::is_unsigned<uint16_t>::value");
+    // typedef uint32_t
+    static_assert(sizeof(uint32_t)*CHAR_BIT == 32,
+                 "sizeof(uint32_t)*CHAR_BIT == 32");
+    static_assert(std::is_unsigned<uint32_t>::value,
+                 "std::is_unsigned<uint32_t>::value");
+    // typedef uint64_t
+    static_assert(sizeof(uint64_t)*CHAR_BIT == 64,
+                 "sizeof(uint64_t)*CHAR_BIT == 64");
+    static_assert(std::is_unsigned<uint64_t>::value,
+                 "std::is_unsigned<uint64_t>::value");
+
+    // typedef int_least8_t
+    static_assert(sizeof(int_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(int_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<int_least8_t>::value,
+                 "std::is_signed<int_least8_t>::value");
+    // typedef int_least16_t
+    static_assert(sizeof(int_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(int_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<int_least16_t>::value,
+                 "std::is_signed<int_least16_t>::value");
+    // typedef int_least32_t
+    static_assert(sizeof(int_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(int_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<int_least32_t>::value,
+                 "std::is_signed<int_least32_t>::value");
+    // typedef int_least64_t
+    static_assert(sizeof(int_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(int_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<int_least64_t>::value,
+                 "std::is_signed<int_least64_t>::value");
+
+    // typedef uint_least8_t
+    static_assert(sizeof(uint_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(uint_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<uint_least8_t>::value,
+                 "std::is_unsigned<uint_least8_t>::value");
+    // typedef uint_least16_t
+    static_assert(sizeof(uint_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(uint_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<uint_least16_t>::value,
+                 "std::is_unsigned<uint_least16_t>::value");
+    // typedef uint_least32_t
+    static_assert(sizeof(uint_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(uint_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<uint_least32_t>::value,
+                 "std::is_unsigned<uint_least32_t>::value");
+    // typedef uint_least64_t
+    static_assert(sizeof(uint_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(uint_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<uint_least64_t>::value,
+                 "std::is_unsigned<uint_least64_t>::value");
+
+    // typedef int_fast8_t
+    static_assert(sizeof(int_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(int_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<int_fast8_t>::value,
+                 "std::is_signed<int_fast8_t>::value");
+    // typedef int_fast16_t
+    static_assert(sizeof(int_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(int_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<int_fast16_t>::value,
+                 "std::is_signed<int_fast16_t>::value");
+    // typedef int_fast32_t
+    static_assert(sizeof(int_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(int_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<int_fast32_t>::value,
+                 "std::is_signed<int_fast32_t>::value");
+    // typedef int_fast64_t
+    static_assert(sizeof(int_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(int_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<int_fast64_t>::value,
+                 "std::is_signed<int_fast64_t>::value");
+
+    // typedef uint_fast8_t
+    static_assert(sizeof(uint_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(uint_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<uint_fast8_t>::value,
+                 "std::is_unsigned<uint_fast8_t>::value");
+    // typedef uint_fast16_t
+    static_assert(sizeof(uint_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(uint_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<uint_fast16_t>::value,
+                 "std::is_unsigned<uint_fast16_t>::value");
+    // typedef uint_fast32_t
+    static_assert(sizeof(uint_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(uint_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<uint_fast32_t>::value,
+                 "std::is_unsigned<uint_fast32_t>::value");
+    // typedef uint_fast64_t
+    static_assert(sizeof(uint_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(uint_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<uint_fast64_t>::value,
+                 "std::is_unsigned<uint_fast64_t>::value");
+
+    // typedef intptr_t
+    static_assert(sizeof(intptr_t) >= sizeof(void*),
+                 "sizeof(intptr_t) >= sizeof(void*)");
+    static_assert(std::is_signed<intptr_t>::value,
+                 "std::is_signed<intptr_t>::value");
+    // typedef uintptr_t
+    static_assert(sizeof(uintptr_t) >= sizeof(void*),
+                 "sizeof(uintptr_t) >= sizeof(void*)");
+    static_assert(std::is_unsigned<uintptr_t>::value,
+                 "std::is_unsigned<uintptr_t>::value");
+
+    // typedef intmax_t
+    static_assert(sizeof(intmax_t) >= sizeof(long long),
+                 "sizeof(intmax_t) >= sizeof(long long)");
+    static_assert(std::is_signed<intmax_t>::value,
+                 "std::is_signed<intmax_t>::value");
+    // typedef uintmax_t
+    static_assert(sizeof(uintmax_t) >= sizeof(unsigned long long),
+                 "sizeof(uintmax_t) >= sizeof(unsigned long long)");
+    static_assert(std::is_unsigned<uintmax_t>::value,
+                 "std::is_unsigned<uintmax_t>::value");
+
+    // INTN_MIN
+    static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+    static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+    static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+    static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+    // INTN_MAX
+    static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+    static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+    static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+    static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+    // UINTN_MAX
+    static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+    static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+    static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+    static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+    // INT_FASTN_MIN
+    static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+    static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+    static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+    static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+    // INT_FASTN_MAX
+    static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+    static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+    static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+    static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+    // UINT_FASTN_MAX
+    static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+    static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+    static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+    static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+    // INTPTR_MIN
+    assert(INTPTR_MIN == std::numeric_limits<intptr_t>::min());
+
+    // INTPTR_MAX
+    assert(INTPTR_MAX == std::numeric_limits<intptr_t>::max());
+
+    // UINTPTR_MAX
+    assert(UINTPTR_MAX == std::numeric_limits<uintptr_t>::max());
+
+    // INTMAX_MIN
+    assert(INTMAX_MIN == std::numeric_limits<intmax_t>::min());
+
+    // INTMAX_MAX
+    assert(INTMAX_MAX == std::numeric_limits<intmax_t>::max());
+
+    // UINTMAX_MAX
+    assert(UINTMAX_MAX == std::numeric_limits<uintmax_t>::max());
+
+    // PTRDIFF_MIN
+    assert(PTRDIFF_MIN == std::numeric_limits<ptrdiff_t>::min());
+
+    // PTRDIFF_MAX
+    assert(PTRDIFF_MAX == std::numeric_limits<ptrdiff_t>::max());
+
+    // SIG_ATOMIC_MIN
+    assert(SIG_ATOMIC_MIN == std::numeric_limits<sig_atomic_t>::min());
+
+    // SIG_ATOMIC_MAX
+    assert(SIG_ATOMIC_MAX == std::numeric_limits<sig_atomic_t>::max());
+
+    // SIZE_MAX
+    assert(SIZE_MAX == std::numeric_limits<size_t>::max());
+
+    // WCHAR_MIN
+    assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+    // WCHAR_MAX
+    assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+    // WINT_MIN
+    assert(WINT_MIN == std::numeric_limits<wint_t>::min());
+
+    // WINT_MAX
+    assert(WINT_MAX == std::numeric_limits<wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/test/depr/depr.c.headers/stdio_h.pass.cpp b/test/depr/depr.c.headers/stdio_h.pass.cpp
new file mode 100644
index 0000000..3e4776f
--- /dev/null
+++ b/test/depr/depr.c.headers/stdio_h.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdio.h>
+
+#include <stdio.h>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+int main()
+{
+    FILE* fp = 0;
+    fpos_t fpos = {0};
+    size_t s = 0;
+    char* cp = 0;
+    va_list va;
+    static_assert((std::is_same<decltype(remove("")), int>::value), "");
+    static_assert((std::is_same<decltype(rename("","")), int>::value), "");
+    static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
+    static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
+    static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
+    static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
+    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(fprintf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(printf("")), int>::value), "");
+    static_assert((std::is_same<decltype(scanf("")), int>::value), "");
+    static_assert((std::is_same<decltype(snprintf(cp,0,"")), int>::value), "");
+    static_assert((std::is_same<decltype(sprintf(cp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
+    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vprintf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsnprintf(cp,0,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsprintf(cp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
+    static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
+    static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
+    static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(getchar()), int>::value), "");
+    static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
+    static_assert((std::is_same<decltype(puts("")), int>::value), "");
+    static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
+    static_assert((std::is_same<decltype(fwrite((const void*)0,0,0,fp)), size_t>::value), "");
+    static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
+    static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
+    static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(perror("")), void>::value), "");
+}
diff --git a/test/depr/depr.c.headers/stdlib_h.pass.cpp b/test/depr/depr.c.headers/stdlib_h.pass.cpp
new file mode 100644
index 0000000..17323b6
--- /dev/null
+++ b/test/depr/depr.c.headers/stdlib_h.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdlib.h>
+
+#include <stdlib.h>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+    size_t s = 0;
+    div_t d;
+    ldiv_t ld;
+    lldiv_t lld;
+    char** endptr = 0;
+    static_assert((std::is_same<decltype(atof("")), double>::value), "");
+    static_assert((std::is_same<decltype(atoi("")), int>::value), "");
+    static_assert((std::is_same<decltype(atol("")), long>::value), "");
+    static_assert((std::is_same<decltype(atoll("")), long long>::value), "");
+    static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(strtod("", endptr)), double>::value), "");
+    static_assert((std::is_same<decltype(strtof("", endptr)), float>::value), "");
+    static_assert((std::is_same<decltype(strtold("", endptr)), long double>::value), "");
+    static_assert((std::is_same<decltype(strtol("", endptr,0)), long>::value), "");
+    static_assert((std::is_same<decltype(strtoll("", endptr,0)), long long>::value), "");
+    static_assert((std::is_same<decltype(strtoul("", endptr,0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(strtoull("", endptr,0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(rand()), int>::value), "");
+    static_assert((std::is_same<decltype(srand(0)), void>::value), "");
+    static_assert((std::is_same<decltype(calloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(free(0)), void>::value), "");
+    static_assert((std::is_same<decltype(malloc(0)), void*>::value), "");
+    static_assert((std::is_same<decltype(realloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(abort()), void>::value), "");
+    static_assert((std::is_same<decltype(atexit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(_Exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(system("")), int>::value), "");
+    static_assert((std::is_same<decltype(bsearch(0,0,0,0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(qsort(0,0,0,0)), void>::value), "");
+    static_assert((std::is_same<decltype(abs(0)), int>::value), "");
+    static_assert((std::is_same<decltype(labs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(llabs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(div(0,0)), div_t>::value), "");
+    static_assert((std::is_same<decltype(ldiv(0L,0L)), ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(lldiv(0LL,0LL)), lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(mblen("",0)), int>::value), "");
+    wchar_t* pw = 0;
+    const wchar_t* pwc = 0;
+    char* pc = 0;
+    static_assert((std::is_same<decltype(mbtowc(pw,"",0)), int>::value), "");
+    static_assert((std::is_same<decltype(wctomb(pc,L' ')), int>::value), "");
+    static_assert((std::is_same<decltype(mbstowcs(pw,"",0)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcstombs(pc,pwc,0)), size_t>::value), "");
+}
diff --git a/test/depr/depr.c.headers/string_h.pass.cpp b/test/depr/depr.c.headers/string_h.pass.cpp
new file mode 100644
index 0000000..a2be7e7
--- /dev/null
+++ b/test/depr/depr.c.headers/string_h.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.h>
+
+#include <string.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    size_t s = 0;
+    void* vp = 0;
+    const void* vpc = 0;
+    char* cp = 0;
+    const char* cpc = 0;
+    static_assert((std::is_same<decltype(memcpy(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(memmove(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strcpy(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strncpy(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(strcat(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strncat(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(memcmp(vpc, vpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(strcmp(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(strncmp(cpc, cpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(strcoll(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(strxfrm(cp, cpc, s)), size_t>::value), "");
+    static_assert((std::is_same<decltype(memchr(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strcspn(cpc, cpc)), size_t>::value), "");
+    static_assert((std::is_same<decltype(strpbrk(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strrchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strspn(cpc, cpc)), size_t>::value), "");
+    static_assert((std::is_same<decltype(strstr(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strtok(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(memset(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strerror(0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strlen(cpc)), size_t>::value), "");
+}
diff --git a/test/depr/depr.c.headers/tgmath_h.pass.cpp b/test/depr/depr.c.headers/tgmath_h.pass.cpp
new file mode 100644
index 0000000..4533b92
--- /dev/null
+++ b/test/depr/depr.c.headers/tgmath_h.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> cd;
+    double x = sin(1.0);
+}
diff --git a/test/depr/depr.c.headers/time_h.pass.cpp b/test/depr/depr.c.headers/time_h.pass.cpp
new file mode 100644
index 0000000..b277523
--- /dev/null
+++ b/test/depr/depr.c.headers/time_h.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <time.h>
+
+#include <time.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    clock_t c = 0;
+    size_t s = 0;
+    time_t t = 0;
+    tm tmv = {0};
+    static_assert((std::is_same<decltype(clock()), clock_t>::value), "");
+    static_assert((std::is_same<decltype(difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(mktime(&tmv)), time_t>::value), "");
+    static_assert((std::is_same<decltype(time(&t)), time_t>::value), "");
+    static_assert((std::is_same<decltype(asctime(&tmv)), char*>::value), "");
+    static_assert((std::is_same<decltype(ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(gmtime(&t)), tm*>::value), "");
+    static_assert((std::is_same<decltype(localtime(&t)), tm*>::value), "");
+    char* c1 = 0;
+    const char* c2 = 0;
+    static_assert((std::is_same<decltype(strftime(c1,s,c2,&tmv)), size_t>::value), "");
+}
diff --git a/test/depr/depr.c.headers/uchar_h.pass.cpp b/test/depr/depr.c.headers/uchar_h.pass.cpp
new file mode 100644
index 0000000..7bd6798
--- /dev/null
+++ b/test/depr/depr.c.headers/uchar_h.pass.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <uchar.h>
+
+#include <uchar.h>
+
+int main()
+{
+}
diff --git a/test/depr/depr.c.headers/wchar_h.pass.cpp b/test/depr/depr.c.headers/wchar_h.pass.cpp
new file mode 100644
index 0000000..cfa8793
--- /dev/null
+++ b/test/depr/depr.c.headers/wchar_h.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <wchar.h>
+
+#include <wchar.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+    mbstate_t mb = {0};
+    size_t s = 0;
+    tm tm = {0};
+    wint_t w = 0;
+    ::FILE* fp = 0;
+    __darwin_va_list va;
+    char* ns = 0;
+    wchar_t* ws = 0;
+    static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(wprintf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wscanf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(getwchar()), wint_t>::value), "");
+    static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), "");
+    static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), "");
+    static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), "");
+    static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+    static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+    static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsftime(ws, s, L"", &tm)), size_t>::value), "");
+    static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wctob(w)), int>::value), "");
+    static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), "");
+    static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), "");
+}
diff --git a/test/depr/depr.c.headers/wctype_h.pass.cpp b/test/depr/depr.c.headers/wctype_h.pass.cpp
new file mode 100644
index 0000000..cca83c5
--- /dev/null
+++ b/test/depr/depr.c.headers/wctype_h.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <wctype.h>
+
+#include <wctype.h>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+    wint_t w = 0;
+    wctrans_t wctr = 0;
+    wctype_t wct = 0;
+    static_assert((std::is_same<decltype(iswalnum(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswalpha(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswblank(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswcntrl(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswgraph(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswlower(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswprint(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswpunct(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswspace(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswupper(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswxdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswctype(w, wct)), int>::value), "");
+    static_assert((std::is_same<decltype(wctype("")), wctype_t>::value), "");
+    static_assert((std::is_same<decltype(towlower(w)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(towupper(w)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(towctrans(w, wctr)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wctrans("")), wctrans_t>::value), "");
+}
diff --git a/test/depr/depr.ios.members/io_state.pass.cpp b/test/depr/depr.ios.members/io_state.pass.cpp
new file mode 100644
index 0000000..87eec0d
--- /dev/null
+++ b/test/depr/depr.ios.members/io_state.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+// 
+// class ios_base
+// {
+// public:
+//     typedef T1 io_state;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::io_state b = std::strstream::eofbit;
+    assert(b == std::ios::eofbit);
+}
diff --git a/test/depr/depr.ios.members/open_mode.pass.cpp b/test/depr/depr.ios.members/open_mode.pass.cpp
new file mode 100644
index 0000000..fb216b0
--- /dev/null
+++ b/test/depr/depr.ios.members/open_mode.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+// 
+// class ios_base
+// {
+// public:
+//     typedef T2 open_mode;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::open_mode b = std::strstream::app;
+    assert(b == std::ios::app);
+}
diff --git a/test/depr/depr.ios.members/seek_dir.pass.cpp b/test/depr/depr.ios.members/seek_dir.pass.cpp
new file mode 100644
index 0000000..358f835
--- /dev/null
+++ b/test/depr/depr.ios.members/seek_dir.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+// 
+// class ios_base
+// {
+// public:
+//     typedef T3 seek_dir;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::seek_dir b = std::strstream::cur;
+    assert(b == std::ios::cur);
+}
diff --git a/test/depr/depr.ios.members/streamoff.pass.cpp b/test/depr/depr.ios.members/streamoff.pass.cpp
new file mode 100644
index 0000000..d7c6d46
--- /dev/null
+++ b/test/depr/depr.ios.members/streamoff.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+// 
+// class ios_base
+// {
+// public:
+//     typedef OFF_T streamoff;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_integral<std::ios_base::streamoff>::value), "");
+    static_assert((std::is_signed<std::ios_base::streamoff>::value), "");
+}
diff --git a/test/depr/depr.ios.members/streampos.pass.cpp b/test/depr/depr.ios.members/streampos.pass.cpp
new file mode 100644
index 0000000..4cc45f1
--- /dev/null
+++ b/test/depr/depr.ios.members/streampos.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+// 
+// class ios_base
+// {
+// public:
+//     typedef POS_T streampos;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::ios_base::streampos, std::streampos>::value), "");
+}
diff --git a/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp b/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
new file mode 100644
index 0000000..9d16702
--- /dev/null
+++ b/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T> 
+//   binder1st<Fn>
+//   bind1st(const Fn& fn, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+    assert(std::bind1st(test_func(1), 5)(10.) == -5.);
+}
diff --git a/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp b/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
new file mode 100644
index 0000000..ed1f706
--- /dev/null
+++ b/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T> 
+//   binder2nd<Fn>
+//   bind2nd(const Fn& op, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+    assert(std::bind2nd(test_func(1), 5)(10) == 5.);
+}
diff --git a/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp b/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
new file mode 100644
index 0000000..f998421
--- /dev/null
+++ b/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn> 
+// class binder1st 
+//   : public unary_function<typename Fn::second_argument_type, typename Fn::result_type>
+// { 
+// protected:
+//   Fn op; 
+//   typename Fn::first_argument_type value;
+// public: 
+//   binder2nd(const Fn& x, const typename Fn::second_argument_type& y); 
+// 
+//   typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const; 
+//   typename Fn::result_type operator()(typename Fn::first_argument_type& x) const; 
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+    : public std::binder1st<test_func>
+{
+    typedef std::binder1st<test_func> base;
+public:
+    test() : std::binder1st<test_func>(test_func(2), 30) {}
+
+    void do_test()
+    {
+        static_assert((std::is_base_of<
+                         std::unary_function<test_func::second_argument_type,
+                                             test_func::result_type>,
+                         test>::value), "");
+        assert(op.id() == 2);
+        assert(value == 30);
+
+        double d = 5;
+        assert((*this)(d) == 35);
+        assert((*this)(5) == 25);
+    }
+};
+
+int main()
+{
+    test t;
+    t.do_test();
+}
diff --git a/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp b/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
new file mode 100644
index 0000000..4477057
--- /dev/null
+++ b/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn> 
+// class binder2nd 
+//   : public unary_function<typename Fn::first_argument_type, typename Fn::result_type>
+// { 
+// protected: 
+//   Fn op; 
+//   typename Fn::second_argument_type value; 
+// public: 
+//   binder2nd(const Fn& x, const typename Fn::second_argument_type& y); 
+// 
+//   typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const; 
+//   typename Fn::result_type operator()(typename Fn::first_argument_type& x) const; 
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+    : public std::binder2nd<test_func>
+{
+    typedef std::binder2nd<test_func> base;
+public:
+    test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
+
+    void do_test()
+    {
+        static_assert((std::is_base_of<
+                         std::unary_function<test_func::first_argument_type,
+                                             test_func::result_type>,
+                         test>::value), "");
+        assert(op.id() == 3);
+        assert(value == 4.5);
+
+        int i = 5;
+        assert((*this)(i) == 22.5);
+        assert((*this)(5) == 0.5);
+    }
+};
+
+int main()
+{
+    test t;
+    t.do_test();
+}
diff --git a/test/depr/depr.lib.binders/nothing_to_do.pass.cpp b/test/depr/depr.lib.binders/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/depr/depr.lib.binders/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/depr/depr.lib.binders/test_func.h b/test/depr/depr.lib.binders/test_func.h
new file mode 100644
index 0000000..1535f34
--- /dev/null
+++ b/test/depr/depr.lib.binders/test_func.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_FUNC_H
+#define TEST_FUNC_H
+
+class test_func
+{
+    int id_;
+public:
+    typedef int first_argument_type;
+    typedef double second_argument_type;
+    typedef long double result_type;
+
+    explicit test_func(int id) : id_(id) {}
+
+    int id() const {return id_;}
+
+    result_type operator() (const first_argument_type& x, second_argument_type& y) const
+        {return x+y;}
+    result_type operator() (const first_argument_type& x, const second_argument_type& y) const
+        {return x-y;}
+    result_type operator() (first_argument_type& x, const second_argument_type& y) const
+        {return x*y;}
+};
+
+#endif
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
new file mode 100644
index 0000000..6b57b60
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "dog");
+        assert(in.eof());
+        assert(!in.fail());
+        in.clear();
+        in.putback('g');
+        assert(!in.fail());
+        in.putback('g');
+        assert(in.fail());
+        assert(buf[9] == 'o');
+        assert(buf[10] == 'g');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
new file mode 100644
index 0000000..f807518
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf, 7);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "");
+        assert(in.eof());
+        assert(in.fail());
+        in.clear();
+        in.putback('5');
+        assert(!in.fail());
+        in.putback('5');
+        assert(in.fail());
+        assert(buf[5] == '.');
+        assert(buf[6] == '5');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
new file mode 100644
index 0000000..910735a
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "dog");
+        assert(in.eof());
+        assert(!in.fail());
+        in.clear();
+        in.putback('g');
+        assert(!in.fail());
+        in.putback('g');
+        assert(!in.fail());
+        assert(buf[9] == 'g');
+        assert(buf[10] == 'g');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
new file mode 100644
index 0000000..40a964f
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::istrstream in(buf, 7);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "");
+        assert(in.eof());
+        assert(in.fail());
+        in.clear();
+        in.putback('5');
+        assert(!in.fail());
+        in.putback('5');
+        assert(!in.fail());
+        assert(buf[5] == '5');
+        assert(buf[6] == '5');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..5a827e1
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        const std::istrstream in(buf);
+        std::strstreambuf* sb = in.rdbuf();
+        assert(sb->sgetc() == '1');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp
new file mode 100644
index 0000000..6f2471c
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        assert(in.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp b/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
new file mode 100644
index 0000000..5f6393b
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+//     : public basic_istream<char>
+// {
+//     ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::istream, std::istrstream>::value), "");
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 0000000..2fda5bf
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::ostrstream out(buf, 0);
+        assert(out.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        out << i << ' ' << d << ' ' << s;
+        assert(out.str() == std::string("321 5.5 cat"));
+    }
+    {
+        char buf[23] = "123 4.5 dog";
+        std::ostrstream out(buf, 11, std::ios::app);
+        assert(out.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        out << i << ' ' << d << ' ' << s;
+        assert(out.str() == std::string("123 4.5 dog321 5.5 cat"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
new file mode 100644
index 0000000..6de537f
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::ostrstream out;
+    int i = 123;
+    double d = 4.5;
+    std::string s("dog");
+    out << i << ' ' << d << ' ' << s;
+    assert(out.str() == std::string("123 4.5 dog"));
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
new file mode 100644
index 0000000..b1c58dd
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        out.freeze();
+        assert(!out.fail());
+        out << 'a';
+        assert(out.fail());
+        out.clear();
+        out.freeze(false);
+        out << 'a';
+        out << char(0);
+        assert(out.str() == std::string("a"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
new file mode 100644
index 0000000..1b2462b
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        assert(out.pcount() == 0);
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.pcount() == 11);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..2c86a6e
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        const std::ostrstream out(buf, 0);
+        std::strstreambuf* sb = out.rdbuf();
+        assert(sb->sputc('a') == 'a');
+        assert(buf == std::string("a23 4.5 dog"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
new file mode 100644
index 0000000..2762dcd
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp b/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
new file mode 100644
index 0000000..5b5c28e
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+//     : public basic_ostream<char>
+// {
+//     ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::ostream, std::ostrstream>::value), "");
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 0000000..33025e5
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::strstream inout(buf, 0);
+        assert(inout.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        inout >> i;
+        assert(inout.fail());
+        inout.clear();
+        inout << i << ' ' << d << ' ' << s;
+        assert(inout.str() == std::string("321 5.5 cat"));
+        i = 0;
+        d = 0;
+        s = "";
+        inout >> i >> d >> s;
+        assert(i == 321);
+        assert(d == 5.5);
+        assert(s == "cat");
+    }
+    {
+        char buf[23] = "123 4.5 dog";
+        std::strstream inout(buf, 11, std::ios::app);
+        assert(inout.str() == std::string("123 4.5 dog"));
+        int i = 0;
+        double d = 0;
+        std::string s;
+        inout >> i >> d >> s;
+        assert(i == 123);
+        assert(d == 4.5);
+        assert(s == "dog");
+        i = 321;
+        d = 5.5;
+        s = "cat";
+        inout.clear();
+        inout << i << ' ' << d << ' ' << s;
+        assert(inout.str() == std::string("123 4.5 dog321 5.5 cat"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
new file mode 100644
index 0000000..c061836
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream inout;
+    int i = 123;
+    double d = 4.5;
+    std::string s("dog");
+    inout << i << ' ' << d << ' ' << s;
+    assert(inout.str() == std::string("123 4.5 dog"));
+    i = 0;
+    d = 0;
+    s = "";
+    inout >> i >> d >> s;
+    assert(i == 123);
+    assert(d == 4.5);
+    assert(s == "dog");
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
new file mode 100644
index 0000000..a619c6a
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        const std::strstream out(buf, 0);
+        std::strstreambuf* sb = out.rdbuf();
+        assert(sb->sputc('a') == 'a');
+        assert(buf == std::string("a23 4.5 dog"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
new file mode 100644
index 0000000..5dbce5d
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        out.freeze();
+        assert(!out.fail());
+        out << 'a';
+        assert(out.fail());
+        out.clear();
+        out.freeze(false);
+        out << 'a';
+        out << char(0);
+        assert(out.str() == std::string("a"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
new file mode 100644
index 0000000..8f3b8f4
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        assert(out.pcount() == 0);
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.pcount() == 11);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
new file mode 100644
index 0000000..02485a9
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp b/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp
new file mode 100644
index 0000000..594420f
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstream/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+//     : public basic_iostream<char>
+// {
+// public:
+//     // Types
+//     typedef char                        char_type;
+//     typedef char_traits<char>::int_type int_type;
+//     typedef char_traits<char>::pos_type pos_type;
+//     typedef char_traits<char>::off_type off_type;
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::iostream, std::strstream>::value), "");
+    static_assert((std::is_same<std::strstream::char_type, char>::value), "");
+    static_assert((std::is_same<std::strstream::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::strstream::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::strstream::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
new file mode 100644
index 0000000..ee767fa
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        const char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
new file mode 100644
index 0000000..3eebeb9
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[10] = "abcd";
+        int s = std::strlen(buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
new file mode 100644
index 0000000..09d4658
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const signed char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        const signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
new file mode 100644
index 0000000..ba982b7
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const unsigned char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
new file mode 100644
index 0000000..83f1805
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
+
+#include <strstream>
+#include <cassert>
+
+int called = 0;
+
+void* my_alloc(std::size_t n)
+{
+    static char buf[10000];
+    ++called;
+    return buf;
+}
+
+void my_free(void*)
+{
+    ++called;
+}
+
+struct test
+    : std::strstreambuf
+{
+    test(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*))
+        : std::strstreambuf(palloc_arg, pfree_arg) {}
+    virtual int_type overflow(int_type c)
+        {return std::strstreambuf::overflow(c);}
+};
+
+int main()
+{
+    {
+        test s(my_alloc, my_free);
+        assert(called == 0);
+        s.overflow('a');
+        assert(called == 1);
+    }
+    assert(called == 2);
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
new file mode 100644
index 0000000..5790efd
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// explicit strstreambuf(streamsize alsize_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf s;
+        assert(s.str() == nullptr);
+        assert(s.pcount() == 0);
+    }
+    {
+        std::strstreambuf s(1024);
+        assert(s.str() == nullptr);
+        assert(s.pcount() == 0);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
new file mode 100644
index 0000000..9416103
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[10] = "abcd";
+        int s = std::strlen((char*)buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
new file mode 100644
index 0000000..7105eae
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[10] = "abcd";
+        int s = std::strlen((char*)buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
new file mode 100644
index 0000000..4b5785d
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        sb.freeze(true);
+        assert(sb.sputc('a') == EOF);
+        sb.freeze(false);
+        assert(sb.sputc('a') == 'a');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
new file mode 100644
index 0000000..c79db6f
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        assert(sb.pcount() == 0);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.pcount() == 1);
+        assert(sb.sputc(0) == 0);
+        assert(sb.pcount() == 2);
+        assert(sb.str() == std::string("a"));
+        assert(sb.pcount() == 2);
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
new file mode 100644
index 0000000..ab68036
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        assert(sb.sputc('a') == 'a');
+        assert(sb.sputc(0) == 0);
+        assert(sb.str() == std::string("a"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..d4ee6b1
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type overflow(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[12] = "abc";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == std::string("1bc"));
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == std::string("12c"));
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == std::string("123"));
+        assert(sb.sputc('4') == '4');
+        assert(sb.str() == std::string("1234"));
+        assert(sb.sputc('5') == '5');
+        assert(sb.str() == std::string("12345"));
+        assert(sb.sputc('6') == '6');
+        assert(sb.str() == std::string("123456"));
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == std::string("1234567"));
+        assert(sb.sputc('8') == '8');
+        assert(sb.str() == std::string("12345678"));
+        assert(sb.sputc('9') == '9');
+        assert(sb.str() == std::string("123456789"));
+        assert(sb.sputc('0') == '0');
+        assert(sb.str() == std::string("1234567890"));
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == std::string("12345678901"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..d2f78ca
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type pbackfail(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+struct test
+    : public std::strstreambuf
+{
+    typedef std::strstreambuf base;
+    test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+        : base(gnext_arg, n, pbeg_arg) {}
+    test(const char* gnext_arg, std::streamsize n)
+        : base(gnext_arg, n) {}
+
+    virtual int_type pbackfail(int_type c = EOF) {return base::pbackfail(c);}
+};
+
+int main()
+{
+    {
+        const char buf[] = "123";
+        test sb(buf, 0);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == EOF);
+        assert(sb.pbackfail('2') == '2');
+        assert(sb.pbackfail(EOF) != EOF);
+        assert(sb.pbackfail(EOF) == EOF);
+        assert(sb.str() == std::string("123"));
+    }
+    {
+        char buf[] = "123";
+        test sb(buf, 0);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail(EOF) != EOF);
+        assert(sb.pbackfail(EOF) == EOF);
+        assert(sb.str() == std::string("133"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..79a5e8c
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way, 
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+    }
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == std::string("012a456789"));
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('b') == 'b');
+        assert(sb.str() == std::string("012a456b89"));
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == std::string("012a456c89"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 0000000..e42bb02
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+    }
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == std::string("012a456789"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 0000000..848d3c9
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// streambuf* setbuf(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == std::string("0123456789"));
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..bbd822d
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type underflow();
+
+#include <strstream>
+#include <cassert>
+
+struct test
+    : public std::strstreambuf
+{
+    typedef std::strstreambuf base;
+    test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+        : base(gnext_arg, n, pbeg_arg) {}
+    test(const char* gnext_arg, std::streamsize n)
+        : base(gnext_arg, n) {}
+
+    base::int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        char buf[10] = "123";
+        test sb(buf, 0, buf + 3);
+        assert(sb.underflow() == '1');
+        assert(sb.underflow() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.underflow() == EOF);
+        assert(sb.underflow() == EOF);
+        sb.sputc('4');
+        assert(sb.underflow() == '4');
+        assert(sb.underflow() == '4');
+    }
+}
diff --git a/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp b/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
new file mode 100644
index 0000000..bd2071b
--- /dev/null
+++ b/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+//     : public basic_streambuf<char>
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::streambuf, std::strstreambuf>::value), "");
+}
diff --git a/test/depr/depr.str.strstreams/version.pass.cpp b/test/depr/depr.str.strstreams/version.pass.cpp
new file mode 100644
index 0000000..69ac842
--- /dev/null
+++ b/test/depr/depr.str.strstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+#include <strstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/depr/nothing_to_do.pass.cpp b/test/depr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/depr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/assertions/cassert.pass.cpp b/test/diagnostics/assertions/cassert.pass.cpp
new file mode 100644
index 0000000..cce5b7a
--- /dev/null
+++ b/test/diagnostics/assertions/cassert.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cassert>
+
+#include <cassert>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp b/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/errno/cerrno.pass.cpp b/test/diagnostics/errno/cerrno.pass.cpp
new file mode 100644
index 0000000..3fd559a
--- /dev/null
+++ b/test/diagnostics/errno/cerrno.pass.cpp
@@ -0,0 +1,341 @@
+// -*- C++ -*-
+//===-------------------------- algorithm ---------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cerrno>
+
+#include <cerrno>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+#ifndef E2BIG
+#error E2BIG not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EADDRINUSE
+#error EADDRINUSE not defined
+#endif
+
+#ifndef EADDRNOTAVAIL
+#error EADDRNOTAVAIL not defined
+#endif
+
+#ifndef EAFNOSUPPORT
+#error EAFNOSUPPORT not defined
+#endif
+
+#ifndef EAGAIN
+#error EAGAIN not defined
+#endif
+
+#ifndef EALREADY
+#error EALREADY not defined
+#endif
+
+#ifndef EBADF
+#error EBADF not defined
+#endif
+
+#ifndef EBADMSG
+#error EBADMSG not defined
+#endif
+
+#ifndef EBUSY
+#error EBUSY not defined
+#endif
+
+#ifndef ECANCELED
+#error ECANCELED not defined
+#endif
+
+#ifndef ECHILD
+#error ECHILD not defined
+#endif
+
+#ifndef ECONNABORTED
+#error ECONNABORTED not defined
+#endif
+
+#ifndef ECONNREFUSED
+#error ECONNREFUSED not defined
+#endif
+
+#ifndef ECONNRESET
+#error ECONNRESET not defined
+#endif
+
+#ifndef EDEADLK
+#error EDEADLK not defined
+#endif
+
+#ifndef EDESTADDRREQ
+#error EDESTADDRREQ not defined
+#endif
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EEXIST
+#error EEXIST not defined
+#endif
+
+#ifndef EFAULT
+#error EFAULT not defined
+#endif
+
+#ifndef EFBIG
+#error EFBIG not defined
+#endif
+
+#ifndef EHOSTUNREACH
+#error EHOSTUNREACH not defined
+#endif
+
+#ifndef EIDRM
+#error EIDRM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef EINPROGRESS
+#error EINPROGRESS not defined
+#endif
+
+#ifndef EINTR
+#error EINTR not defined
+#endif
+
+#ifndef EINVAL
+#error EINVAL not defined
+#endif
+
+#ifndef EIO
+#error EIO not defined
+#endif
+
+#ifndef EISCONN
+#error EISCONN not defined
+#endif
+
+#ifndef EISDIR
+#error EISDIR not defined
+#endif
+
+#ifndef ELOOP
+#error ELOOP not defined
+#endif
+
+#ifndef EMFILE
+#error EMFILE not defined
+#endif
+
+#ifndef EMLINK
+#error EMLINK not defined
+#endif
+
+#ifndef EMSGSIZE
+#error EMSGSIZE not defined
+#endif
+
+#ifndef ENAMETOOLONG
+#error ENAMETOOLONG not defined
+#endif
+
+#ifndef ENETDOWN
+#error ENETDOWN not defined
+#endif
+
+#ifndef ENETRESET
+#error ENETRESET not defined
+#endif
+
+#ifndef ENETUNREACH
+#error ENETUNREACH not defined
+#endif
+
+#ifndef ENFILE
+#error ENFILE not defined
+#endif
+
+#ifndef ENOBUFS
+#error ENOBUFS not defined
+#endif
+
+#ifndef ENODATA
+#error ENODATA not defined
+#endif
+
+#ifndef ENODEV
+#error ENODEV not defined
+#endif
+
+#ifndef ENOENT
+#error ENOENT not defined
+#endif
+
+#ifndef ENOEXEC
+#error ENOEXEC not defined
+#endif
+
+#ifndef ENOLCK
+#error ENOLCK not defined
+#endif
+
+#ifndef ENOLINK
+#error ENOLINK not defined
+#endif
+
+#ifndef ENOMEM
+#error ENOMEM not defined
+#endif
+
+#ifndef ENOMSG
+#error ENOMSG not defined
+#endif
+
+#ifndef ENOPROTOOPT
+#error ENOPROTOOPT not defined
+#endif
+
+#ifndef ENOSPC
+#error ENOSPC not defined
+#endif
+
+#ifndef ENOSR
+#error ENOSR not defined
+#endif
+
+#ifndef ENOSTR
+#error ENOSTR not defined
+#endif
+
+#ifndef ENOSYS
+#error ENOSYS not defined
+#endif
+
+#ifndef ENOTCONN
+#error ENOTCONN not defined
+#endif
+
+#ifndef ENOTDIR
+#error ENOTDIR not defined
+#endif
+
+#ifndef ENOTEMPTY
+#error ENOTEMPTY not defined
+#endif
+
+#ifndef ENOTRECOVERABLE
+#error ENOTRECOVERABLE not defined
+#endif
+
+#ifndef ENOTSOCK
+#error ENOTSOCK not defined
+#endif
+
+#ifndef ENOTSUP
+#error ENOTSUP not defined
+#endif
+
+#ifndef ENOTTY
+#error ENOTTY not defined
+#endif
+
+#ifndef ENXIO
+#error ENXIO not defined
+#endif
+
+#ifndef EOPNOTSUPP
+#error EOPNOTSUPP not defined
+#endif
+
+#ifndef EOVERFLOW
+#error EOVERFLOW not defined
+#endif
+
+#ifndef EOWNERDEAD
+#error EOWNERDEAD not defined
+#endif
+
+#ifndef EPERM
+#error EPERM not defined
+#endif
+
+#ifndef EPIPE
+#error EPIPE not defined
+#endif
+
+#ifndef EPROTO
+#error EPROTO not defined
+#endif
+
+#ifndef EPROTONOSUPPORT
+#error EPROTONOSUPPORT not defined
+#endif
+
+#ifndef EPROTOTYPE
+#error EPROTOTYPE not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef EROFS
+#error EROFS not defined
+#endif
+
+#ifndef ESPIPE
+#error ESPIPE not defined
+#endif
+
+#ifndef ESRCH
+#error ESRCH not defined
+#endif
+
+#ifndef ETIME
+#error ETIME not defined
+#endif
+
+#ifndef ETIMEDOUT
+#error ETIMEDOUT not defined
+#endif
+
+#ifndef ETXTBSY
+#error ETXTBSY not defined
+#endif
+
+#ifndef EWOULDBLOCK
+#error EWOULDBLOCK not defined
+#endif
+
+#ifndef EXDEV
+#error EXDEV not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/diagnostics/nothing_to_do.pass.cpp b/test/diagnostics/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp b/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
new file mode 100644
index 0000000..22ab9a2
--- /dev/null
+++ b/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test domain_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::domain_error>::value),
+                 "std::is_base_of<std::logic_error, std::domain_error>::value");
+    static_assert(std::is_polymorphic<std::domain_error>::value,
+                 "std::is_polymorphic<std::domain_error>::value");
+    {
+    const char* msg = "domain_error message";
+    std::domain_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::domain_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another domain_error message");
+    std::domain_error e(msg);
+    assert(e.what() == msg);
+    std::domain_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp b/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
new file mode 100644
index 0000000..bfe324a
--- /dev/null
+++ b/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test invalid_argument
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::invalid_argument>::value),
+                 "std::is_base_of<std::logic_error, std::invalid_argument>::value");
+    static_assert(std::is_polymorphic<std::invalid_argument>::value,
+                 "std::is_polymorphic<std::invalid_argument>::value");
+    {
+    const char* msg = "invalid_argument message";
+    std::invalid_argument e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::invalid_argument e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another invalid_argument message");
+    std::invalid_argument e(msg);
+    assert(e.what() == msg);
+    std::invalid_argument e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp b/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp
new file mode 100644
index 0000000..e6f9860
--- /dev/null
+++ b/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test length_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::length_error>::value),
+                 "std::is_base_of<std::logic_error, std::length_error>::value");
+    static_assert(std::is_polymorphic<std::length_error>::value,
+                 "std::is_polymorphic<std::length_error>::value");
+    {
+    const char* msg = "length_error message";
+    std::length_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::length_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another length_error message");
+    std::length_error e(msg);
+    assert(e.what() == msg);
+    std::length_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp b/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
new file mode 100644
index 0000000..a668290
--- /dev/null
+++ b/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test logic_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::logic_error>::value),
+                 "std::is_base_of<std::exception, std::logic_error>::value");
+    static_assert(std::is_polymorphic<std::logic_error>::value,
+                 "std::is_polymorphic<std::logic_error>::value");
+    {
+    const char* msg = "logic_error message";
+    std::logic_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::logic_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another logic_error message");
+    std::logic_error e(msg);
+    assert(e.what() == msg);
+    std::logic_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp b/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
new file mode 100644
index 0000000..1b6a577
--- /dev/null
+++ b/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test out_of_range
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::out_of_range>::value),
+                 "std::is_base_of<std::logic_error, std::out_of_range>::value");
+    static_assert(std::is_polymorphic<std::out_of_range>::value,
+                 "std::is_polymorphic<std::out_of_range>::value");
+    {
+    const char* msg = "out_of_range message";
+    std::out_of_range e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::out_of_range e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another out_of_range message");
+    std::out_of_range e(msg);
+    assert(e.what() == msg);
+    std::out_of_range e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp b/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
new file mode 100644
index 0000000..2d795c3
--- /dev/null
+++ b/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test overflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::overflow_error>::value),
+                 "std::is_base_of<std::runtime_error, std::overflow_error>::value");
+    static_assert(std::is_polymorphic<std::overflow_error>::value,
+                 "std::is_polymorphic<std::overflow_error>::value");
+    {
+    const char* msg = "overflow_error message";
+    std::overflow_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::overflow_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another overflow_error message");
+    std::overflow_error e(msg);
+    assert(e.what() == msg);
+    std::overflow_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp b/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp
new file mode 100644
index 0000000..6b5ce3c
--- /dev/null
+++ b/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test range_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::range_error>::value),
+                 "std::is_base_of<std::runtime_error, std::range_error>::value");
+    static_assert(std::is_polymorphic<std::range_error>::value,
+                 "std::is_polymorphic<std::range_error>::value");
+    {
+    const char* msg = "range_error message";
+    std::range_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::range_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another range_error message");
+    std::range_error e(msg);
+    assert(e.what() == msg);
+    std::range_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp b/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
new file mode 100644
index 0000000..9635a3e
--- /dev/null
+++ b/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test runtime_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::runtime_error>::value),
+                 "std::is_base_of<std::exception, std::runtime_error>::value");
+    static_assert(std::is_polymorphic<std::runtime_error>::value,
+                 "std::is_polymorphic<std::runtime_error>::value");
+    {
+    const char* msg = "runtime_error message";
+    std::runtime_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::runtime_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another runtime_error message");
+    std::runtime_error e(msg);
+    assert(e.what() == msg);
+    std::runtime_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp b/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
new file mode 100644
index 0000000..6d1183b
--- /dev/null
+++ b/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test underflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::underflow_error>::value),
+                 "std::is_base_of<std::runtime_error, std::underflow_error>::value");
+    static_assert(std::is_polymorphic<std::underflow_error>::value,
+                 "std::is_polymorphic<std::underflow_error>::value");
+    {
+    const char* msg = "underflow_error message";
+    std::underflow_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::underflow_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another underflow_error message");
+    std::underflow_error e(msg);
+    assert(e.what() == msg);
+    std::underflow_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/test/diagnostics/std.exceptions/version.pass.cpp b/test/diagnostics/std.exceptions/version.pass.cpp
new file mode 100644
index 0000000..4a813f0
--- /dev/null
+++ b/test/diagnostics/std.exceptions/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <stdexcept>
+
+#include <stdexcept>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/errc.pass.cpp b/test/diagnostics/syserr/errc.pass.cpp
new file mode 100644
index 0000000..976e5d0
--- /dev/null
+++ b/test/diagnostics/syserr/errc.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// enum errc {...}
+
+#include <system_error>
+
+int main()
+{
+    static_assert(std::errc::address_family_not_supported == EAFNOSUPPORT, "");
+    static_assert(std::errc::address_in_use == EADDRINUSE, "");
+    static_assert(std::errc::address_not_available == EADDRNOTAVAIL, "");
+    static_assert(std::errc::already_connected == EISCONN, "");
+    static_assert(std::errc::argument_list_too_long == E2BIG, "");
+    static_assert(std::errc::argument_out_of_domain == EDOM, "");
+    static_assert(std::errc::bad_address == EFAULT, "");
+    static_assert(std::errc::bad_file_descriptor == EBADF, "");
+    static_assert(std::errc::bad_message == EBADMSG, "");
+    static_assert(std::errc::broken_pipe == EPIPE, "");
+    static_assert(std::errc::connection_aborted == ECONNABORTED, "");
+    static_assert(std::errc::connection_already_in_progress == EALREADY, "");
+    static_assert(std::errc::connection_refused == ECONNREFUSED, "");
+    static_assert(std::errc::connection_reset == ECONNRESET, "");
+    static_assert(std::errc::cross_device_link == EXDEV, "");
+    static_assert(std::errc::destination_address_required == EDESTADDRREQ, "");
+    static_assert(std::errc::device_or_resource_busy == EBUSY, "");
+    static_assert(std::errc::directory_not_empty == ENOTEMPTY, "");
+    static_assert(std::errc::executable_format_error == ENOEXEC, "");
+    static_assert(std::errc::file_exists == EEXIST, "");
+    static_assert(std::errc::file_too_large == EFBIG, "");
+    static_assert(std::errc::filename_too_long == ENAMETOOLONG, "");
+    static_assert(std::errc::function_not_supported == ENOSYS, "");
+    static_assert(std::errc::host_unreachable == EHOSTUNREACH, "");
+    static_assert(std::errc::identifier_removed == EIDRM, "");
+    static_assert(std::errc::illegal_byte_sequence == EILSEQ, "");
+    static_assert(std::errc::inappropriate_io_control_operation == ENOTTY, "");
+    static_assert(std::errc::interrupted == EINTR, "");
+    static_assert(std::errc::invalid_argument == EINVAL, "");
+    static_assert(std::errc::invalid_seek == ESPIPE, "");
+    static_assert(std::errc::io_error == EIO, "");
+    static_assert(std::errc::is_a_directory == EISDIR, "");
+    static_assert(std::errc::message_size == EMSGSIZE, "");
+    static_assert(std::errc::network_down == ENETDOWN, "");
+    static_assert(std::errc::network_reset == ENETRESET, "");
+    static_assert(std::errc::network_unreachable == ENETUNREACH, "");
+    static_assert(std::errc::no_buffer_space == ENOBUFS, "");
+    static_assert(std::errc::no_child_process == ECHILD, "");
+    static_assert(std::errc::no_link == ENOLINK, "");
+    static_assert(std::errc::no_lock_available == ENOLCK, "");
+    static_assert(std::errc::no_message_available == ENODATA, "");
+    static_assert(std::errc::no_message == ENOMSG, "");
+    static_assert(std::errc::no_protocol_option == ENOPROTOOPT, "");
+    static_assert(std::errc::no_space_on_device == ENOSPC, "");
+    static_assert(std::errc::no_stream_resources == ENOSR, "");
+    static_assert(std::errc::no_such_device_or_address == ENXIO, "");
+    static_assert(std::errc::no_such_device == ENODEV, "");
+    static_assert(std::errc::no_such_file_or_directory == ENOENT, "");
+    static_assert(std::errc::no_such_process == ESRCH, "");
+    static_assert(std::errc::not_a_directory == ENOTDIR, "");
+    static_assert(std::errc::not_a_socket == ENOTSOCK, "");
+    static_assert(std::errc::not_a_stream == ENOSTR, "");
+    static_assert(std::errc::not_connected == ENOTCONN, "");
+    static_assert(std::errc::not_enough_memory == ENOMEM, "");
+    static_assert(std::errc::not_supported == ENOTSUP, "");
+    static_assert(std::errc::operation_canceled == ECANCELED, "");
+    static_assert(std::errc::operation_in_progress == EINPROGRESS, "");
+    static_assert(std::errc::operation_not_permitted == EPERM, "");
+    static_assert(std::errc::operation_not_supported == EOPNOTSUPP, "");
+    static_assert(std::errc::operation_would_block == EWOULDBLOCK, "");
+    static_assert(std::errc::owner_dead == EOWNERDEAD, "");
+    static_assert(std::errc::permission_denied == EACCES, "");
+    static_assert(std::errc::protocol_error == EPROTO, "");
+    static_assert(std::errc::protocol_not_supported == EPROTONOSUPPORT, "");
+    static_assert(std::errc::read_only_file_system == EROFS, "");
+    static_assert(std::errc::resource_deadlock_would_occur == EDEADLK, "");
+    static_assert(std::errc::resource_unavailable_try_again == EAGAIN, "");
+    static_assert(std::errc::result_out_of_range == ERANGE, "");
+    static_assert(std::errc::state_not_recoverable == ENOTRECOVERABLE, "");
+    static_assert(std::errc::stream_timeout == ETIME, "");
+    static_assert(std::errc::text_file_busy == ETXTBSY, "");
+    static_assert(std::errc::timed_out == ETIMEDOUT, "");
+    static_assert(std::errc::too_many_files_open_in_system == ENFILE, "");
+    static_assert(std::errc::too_many_files_open == EMFILE, "");
+    static_assert(std::errc::too_many_links == EMLINK, "");
+    static_assert(std::errc::too_many_symbolic_link_levels == ELOOP, "");
+    static_assert(std::errc::value_too_large == EOVERFLOW, "");
+    static_assert(std::errc::wrong_protocol_type == EPROTOTYPE, "");
+}
diff --git a/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp b/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp
new file mode 100644
index 0000000..99f5b4f
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// bool operator==(const error_code&      lhs, const error_code&      rhs);
+// bool operator==(const error_code&      lhs, const error_condition& rhs);
+// bool operator==(const error_condition& lhs, const error_code&      rhs);
+// bool operator==(const error_condition& lhs, const error_condition& rhs);
+// bool operator!=(const error_code&      lhs, const error_code&      rhs);
+// bool operator!=(const error_code&      lhs, const error_condition& rhs);
+// bool operator!=(const error_condition& lhs, const error_code&      rhs);
+// bool operator!=(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_code e_code1(5, std::generic_category());
+    std::error_code e_code2(5, std::system_category());
+    std::error_code e_code3(6, std::generic_category());
+    std::error_code e_code4(6, std::system_category());
+    std::error_condition e_condition1(5, std::generic_category());
+    std::error_condition e_condition2(5, std::system_category());
+    std::error_condition e_condition3(6, std::generic_category());
+    std::error_condition e_condition4(6, std::system_category());
+
+    assert(e_code1 == e_code1);
+    assert(e_code1 != e_code2);
+    assert(e_code1 != e_code3);
+    assert(e_code1 != e_code4);
+    assert(e_code1 == e_condition1);
+    assert(e_code1 != e_condition2);
+    assert(e_code1 != e_condition3);
+    assert(e_code1 != e_condition4);
+
+    assert(e_code2 != e_code1);
+    assert(e_code2 == e_code2);
+    assert(e_code2 != e_code3);
+    assert(e_code2 != e_code4);
+    assert(e_code2 == e_condition1);  // ?
+    assert(e_code2 == e_condition2);
+    assert(e_code2 != e_condition3);
+    assert(e_code2 != e_condition4);
+
+    assert(e_code3 != e_code1);
+    assert(e_code3 != e_code2);
+    assert(e_code3 == e_code3);
+    assert(e_code3 != e_code4);
+    assert(e_code3 != e_condition1);
+    assert(e_code3 != e_condition2);
+    assert(e_code3 == e_condition3);
+    assert(e_code3 != e_condition4);
+
+    assert(e_code4 != e_code1);
+    assert(e_code4 != e_code2);
+    assert(e_code4 != e_code3);
+    assert(e_code4 == e_code4);
+    assert(e_code4 != e_condition1);
+    assert(e_code4 != e_condition2);
+    assert(e_code4 == e_condition3);  // ?
+    assert(e_code4 == e_condition4);
+
+    assert(e_condition1 == e_code1);
+    assert(e_condition1 == e_code2);  // ?
+    assert(e_condition1 != e_code3);
+    assert(e_condition1 != e_code4);
+    assert(e_condition1 == e_condition1);
+    assert(e_condition1 != e_condition2);
+    assert(e_condition1 != e_condition3);
+    assert(e_condition1 != e_condition4);
+
+    assert(e_condition2 != e_code1);
+    assert(e_condition2 == e_code2);
+    assert(e_condition2 != e_code3);
+    assert(e_condition2 != e_code4);
+    assert(e_condition2 != e_condition1);
+    assert(e_condition2 == e_condition2);
+    assert(e_condition2 != e_condition3);
+    assert(e_condition2 != e_condition4);
+
+    assert(e_condition3 != e_code1);
+    assert(e_condition3 != e_code2);
+    assert(e_condition3 == e_code3);
+    assert(e_condition3 == e_code4);  // ?
+    assert(e_condition3 != e_condition1);
+    assert(e_condition3 != e_condition2);
+    assert(e_condition3 == e_condition3);
+    assert(e_condition3 != e_condition4);
+
+    assert(e_condition4 != e_code1);
+    assert(e_condition4 != e_code2);
+    assert(e_condition4 != e_code3);
+    assert(e_condition4 == e_code4);
+    assert(e_condition4 != e_condition1);
+    assert(e_condition4 != e_condition2);
+    assert(e_condition4 != e_condition3);
+    assert(e_condition4 == e_condition4);
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
new file mode 100644
index 0000000..b73ae1e
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual string message(int ev) const = 0;
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+#include <stdio.h>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::system_category();
+    std::string m1 = e_cat1.message(5);
+    std::string m2 = e_cat2.message(5);
+    std::string m3 = e_cat2.message(6);
+    assert(!m1.empty());
+    assert(!m2.empty());
+    assert(!m3.empty());
+    assert(m1 == m2);
+    assert(m1 != m3);
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp
new file mode 100644
index 0000000..d6e72f8
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator==(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(e_cat1 == e_cat2);
+    assert(!(e_cat1 == e_cat3));
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp
new file mode 100644
index 0000000..4ede85c
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator<(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(!(e_cat1 < e_cat2) && !(e_cat2 < e_cat1));
+    assert((e_cat1 < e_cat3) || (e_cat3 < e_cat1));
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp
new file mode 100644
index 0000000..077c57d
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator!=(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(!(e_cat1 != e_cat2));
+    assert(e_cat1 != e_cat3);
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
new file mode 100644
index 0000000..fcfb2ce
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& generic_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    std::string m1 = e_cat1.name();
+    assert(m1 == "generic");
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
new file mode 100644
index 0000000..69b009f
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& system_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::system_category();
+    std::error_condition e_cond = e_cat1.default_error_condition(5);
+    assert(e_cond.value() == 5);
+    assert(e_cond.category() == std::generic_category());
+    e_cond = e_cat1.default_error_condition(500);
+    assert(e_cond.value() == 500);
+    assert(e_cond.category() == std::system_category());
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
new file mode 100644
index 0000000..444329a
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+#include <system_error>
+
+int main()
+{
+    std::error_category* p = 0;
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
new file mode 100644
index 0000000..680c1a9
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual error_condition default_error_condition(int ev) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    std::error_condition e_cond = e_cat.default_error_condition(std::errc::not_a_directory);
+    assert(e_cond.category() == e_cat);
+    assert(e_cond.value() == std::errc::not_a_directory);
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
new file mode 100644
index 0000000..d2784bf
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(const error_code& code, int condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    assert(e_cat.equivalent(std::error_code(5, e_cat), 5));
+    assert(!e_cat.equivalent(std::error_code(5, e_cat), 6));
+}
diff --git a/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
new file mode 100644
index 0000000..6b93885
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(int code, const error_condition& condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    std::error_condition e_cond = e_cat.default_error_condition(5);
+    assert(e_cat.equivalent(5, e_cond));
+    assert(!e_cat.equivalent(6, e_cond));
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000..fe0acb4
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code(E e); 
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+    zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+    return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+    {
+        std::error_code ec(two);
+        assert(ec.value() == 2);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
new file mode 100644
index 0000000..b5f1145
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_code ec;
+    assert(ec.value() == 0);
+    assert(ec.category() == std::system_category());
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
new file mode 100644
index 0000000..e7159e7
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_code ec(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000..26e7b2e
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+    zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+    return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec = two;
+        assert(ec.value() == 2);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
new file mode 100644
index 0000000..c726b00
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_code ec;
+        ec.assign(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..7fa97e0
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec.assign(6, std::generic_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::generic_category());
+        ec.clear();
+        assert(ec.value() == 0);
+        assert(ec.category() == std::system_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
new file mode 100644
index 0000000..fb739d8
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// bool operator<(const error_code& lhs, const error_code& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec1(6, std::generic_category());
+        const std::error_code ec2(7, std::generic_category());
+        assert(ec1 < ec2);
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
new file mode 100644
index 0000000..c0b9c0f
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code make_error_code(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = make_error_code(std::errc::operation_canceled);
+        assert(ec.value() == static_cast<int>(std::errc::operation_canceled));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
new file mode 100644
index 0000000..255d807
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <class charT, class traits> 
+//   basic_ostream<charT,traits>& 
+//   operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+#include <system_error>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream out;
+    out << std::error_code(std::io_errc::stream);
+    assert(out.str() == "iostream:1");
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
new file mode 100644
index 0000000..73a2970
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec(6, std::generic_category());
+        assert(static_cast<bool>(ec));
+    }
+    {
+        const std::error_code ec(0, std::generic_category());
+        assert(!static_cast<bool>(ec));
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
new file mode 100644
index 0000000..47ae300
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::generic_category());
+    assert(ec.category() == std::generic_category());
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
new file mode 100644
index 0000000..5c7f9c3
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_condition default_error_condition() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec(6, std::generic_category());
+        std::error_condition e_cond = ec.default_error_condition();
+        assert(e_cond == ec);
+    }
+    {
+        const std::error_code ec(6, std::system_category());
+        std::error_condition e_cond = ec.default_error_condition();
+        assert(e_cond == ec);
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
new file mode 100644
index 0000000..0e7d127
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::generic_category());
+    assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
new file mode 100644
index 0000000..e52ca85
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::system_category());
+    assert(ec.value() == 6);
+}
diff --git a/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp
new file mode 100644
index 0000000..36a8f2e
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition(E e); 
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec(std::errc::not_a_directory);
+        assert(ec.value() == static_cast<int>(std::errc::not_a_directory));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
new file mode 100644
index 0000000..517185d
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_condition ec;
+    assert(ec.value() == 0);
+    assert(ec.category() == std::generic_category());
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
new file mode 100644
index 0000000..33ef4c4
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_condition ec(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
new file mode 100644
index 0000000..12276ed
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec = std::errc::not_enough_memory;
+        assert(ec.value() == static_cast<int>(std::errc::not_enough_memory));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
new file mode 100644
index 0000000..341df8a
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_condition ec;
+        ec.assign(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..0249889
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+        ec.clear();
+        assert(ec.value() == 0);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
new file mode 100644
index 0000000..9bd5b93
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// bool operator<(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1(6, std::generic_category());
+        const std::error_condition ec2(7, std::generic_category());
+        assert(ec1 < ec2);
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp
new file mode 100644
index 0000000..9182b66
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition make_error_condition(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1 = std::make_error_condition(std::errc::message_size);
+        assert(ec1.value() == static_cast<int>(std::errc::message_size));
+        assert(ec1.category() == std::generic_category());
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
new file mode 100644
index 0000000..4425763
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec(6, std::generic_category());
+        assert(static_cast<bool>(ec));
+    }
+    {
+        const std::error_condition ec(0, std::generic_category());
+        assert(!static_cast<bool>(ec));
+    }
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
new file mode 100644
index 0000000..7b7d678
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::generic_category());
+    assert(ec.category() == std::generic_category());
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
new file mode 100644
index 0000000..4e9e61e
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::generic_category());
+    assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
new file mode 100644
index 0000000..5dcc422
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::system_category());
+    assert(ec.value() == 6);
+}
diff --git a/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp
new file mode 100644
index 0000000..aa8f29c
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <system_error>
+#include <cassert>
+#include <type_traits>
+
+void
+test(int i)
+{
+    typedef std::error_code T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    T ec(i, std::system_category());
+    assert(h(ec) == i);
+}
+
+int main()
+{
+    test(0);
+    test(2);
+    test(10);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
new file mode 100644
index 0000000..6a810fe
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), "some text");
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
new file mode 100644
index 0000000..39a7d99
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(make_error_code(std::errc::not_a_directory), what_arg.c_str());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
new file mode 100644
index 0000000..fe16dc6
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(make_error_code(std::errc::not_a_directory), what_arg);
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
new file mode 100644
index 0000000..8400376
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
new file mode 100644
index 0000000..a276109
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), what_arg.c_str());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
new file mode 100644
index 0000000..cf07d4d
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), what_arg);
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/diagnostics/syserr/version.pass.cpp b/test/diagnostics/syserr/version.pass.cpp
new file mode 100644
index 0000000..3147fed
--- /dev/null
+++ b/test/diagnostics/syserr/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+#include <system_error>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/file.streams/c.files/cinttypes.pass.cpp b/test/input.output/file.streams/c.files/cinttypes.pass.cpp
new file mode 100644
index 0000000..23f1dbe
--- /dev/null
+++ b/test/input.output/file.streams/c.files/cinttypes.pass.cpp
@@ -0,0 +1,929 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cinttypes>
+
+#include <cinttypes>
+#include <type_traits>
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+    {
+    std::int8_t  i1 = 0;
+    std::int16_t i2 = 0;
+    std::int32_t i3 = 0;
+    std::int64_t i4 = 0;
+    }
+    {
+    std::uint8_t  i1 = 0;
+    std::uint16_t i2 = 0;
+    std::uint32_t i3 = 0;
+    std::uint64_t i4 = 0;
+    }
+    {
+    std::int_least8_t  i1 = 0;
+    std::int_least16_t i2 = 0;
+    std::int_least32_t i3 = 0;
+    std::int_least64_t i4 = 0;
+    }
+    {
+    std::uint_least8_t  i1 = 0;
+    std::uint_least16_t i2 = 0;
+    std::uint_least32_t i3 = 0;
+    std::uint_least64_t i4 = 0;
+    }
+    {
+    std::int_fast8_t  i1 = 0;
+    std::int_fast16_t i2 = 0;
+    std::int_fast32_t i3 = 0;
+    std::int_fast64_t i4 = 0;
+    }
+    {
+    std::uint_fast8_t  i1 = 0;
+    std::uint_fast16_t i2 = 0;
+    std::uint_fast32_t i3 = 0;
+    std::uint_fast64_t i4 = 0;
+    }
+    {
+    std::intptr_t  i1 = 0;
+    std::uintptr_t i2 = 0;
+    std::intmax_t  i3 = 0;
+    std::uintmax_t i4 = 0;
+    }
+    {
+    std::imaxdiv_t  i1 = {0};
+    }
+    std::intmax_t i = 0;
+    static_assert((std::is_same<decltype(std::imaxabs(i)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::imaxdiv(i, i)), std::imaxdiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::strtoimax("", (char**)0, 0)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::strtoumax("", (char**)0, 0)), std::uintmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoimax(L"", (wchar_t**)0, 0)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoumax(L"", (wchar_t**)0, 0)), std::uintmax_t>::value), "");
+}
diff --git a/test/input.output/file.streams/c.files/cstdio.pass.cpp b/test/input.output/file.streams/c.files/cstdio.pass.cpp
new file mode 100644
index 0000000..4b90909
--- /dev/null
+++ b/test/input.output/file.streams/c.files/cstdio.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdio>
+
+#include <cstdio>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+int main()
+{
+    std::FILE* fp = 0;
+    std::fpos_t fpos = {0};
+    std::size_t s = 0;
+    char* cp = 0;
+    std::va_list va;
+    static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
+    static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fprintf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::printf("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::scanf("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::snprintf(cp,0,"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::sprintf(cp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vprintf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsnprintf(cp,0,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsprintf(cp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
+    static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), "");
+    static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::feof(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::perror("")), void>::value), "");
+}
diff --git a/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp b/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp
new file mode 100644
index 0000000..eeba006
--- /dev/null
+++ b/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdio>
+
+#include <cstdio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp b/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp
new file mode 100644
index 0000000..d7018b8
--- /dev/null
+++ b/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cinttypes>
+
+#include <cinttypes>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..248c5cd
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// void swap(basic_filebuf& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        f2.swap(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    remove("test.dat");
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        f2.swap(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..24e1f74
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf& operator=(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        f2 = move(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    remove("test.dat");
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        f2 = move(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..cbb9dfd
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// template <class charT, class traits> 
+// void
+// swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        swap(f2, f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    remove("test.dat");
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        swap(f2, f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
new file mode 100644
index 0000000..61f4399
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::filebuf f;
+        assert(!f.is_open());
+    }
+    {
+        std::wfilebuf f;
+        assert(!f.is_open());
+    }
+}    
diff --git a/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
new file mode 100644
index 0000000..d04ed73
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2(move(f));
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    remove("test.dat");
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
+                                                     | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2(move(f));
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..151521d
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+    }
+    {
+        std::filebuf f;
+        assert(f.open("test.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sbumpc() == '2');
+        assert(f.sbumpc() == '3');
+    }
+    remove("test.dat");
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+    }
+    {
+        std::wfilebuf f;
+        assert(f.open("test.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == L'1');
+        assert(f.sbumpc() == L'2');
+        assert(f.sbumpc() == L'3');
+    }
+    remove("test.dat");
+}    
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..c01942b
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type overflow(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT>  base;
+    typedef typename base::char_type   char_type;
+    typedef typename base::int_type    int_type;
+    typedef typename base::traits_type traits_type;
+
+    char_type* pbase() const {return base::pbase();}
+    char_type* pptr()  const {return base::pptr();}
+    char_type* epptr() const {return base::epptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow('a') == 'a');
+        assert(f.pbase() != 0);
+        assert(f.pptr() == f.pbase());
+        assert(f.epptr() - f.pbase() == 4095);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == 'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<char> f;
+        f.pubsetbuf(0, 0);
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow('a') == 'a');
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == 'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow(L'a') == L'a');
+        assert(f.pbase() != 0);
+        assert(f.pptr() == f.pbase());
+        assert(f.epptr() - f.pbase() == 4095);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        f.pubsetbuf(0, 0);
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow(L'a') == L'a');
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        f.pubimbue(std::locale("en_US.UTF-8"));
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.sputc(0x4E51) == 0x4E51);
+        assert(f.sputc(0x4E52) == 0x4E52);
+        assert(f.sputc(0x4E53) == 0x4E53);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x91);
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x92);
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x93);
+        assert(f.sbumpc() == -1);
+    }
+    std::remove("overflow.dat");
+}    
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..4b0a165
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type pbackfail(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT>  base;
+    typedef typename base::char_type   char_type;
+    typedef typename base::int_type    int_type;
+    typedef typename base::traits_type traits_type;
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sgetc() == '2');
+        assert(f.pbackfail('a') == -1);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sgetc() == '2');
+        assert(f.pbackfail('a') == 'a');
+        assert(f.sbumpc() == 'a');
+        assert(f.sgetc() == '2');
+    }
+}    
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..27584ca
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// pos_type seekoff(off_type off, ios_base::seekdir way, 
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+// pos_type seekpos(pos_type sp, 
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT> base;
+    typedef typename base::char_type  char_type;
+    typedef typename base::int_type   int_type;
+    typedef typename base::pos_type   pos_type;
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        char buf[10];
+        typedef std::filebuf::pos_type pos_type;
+        std::filebuf f;
+        f.pubsetbuf(buf, sizeof(buf));
+        assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
+        assert(buf[0] == 'v');
+        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+        assert(p == 11);
+        assert(f.sgetc() == 'l');
+        f.pubseekoff(0, std::ios_base::beg);
+        assert(f.sgetc() == 'a');
+        f.pubseekoff(-1, std::ios_base::end);
+        assert(f.sgetc() == 'z');
+        assert(f.pubseekpos(p) == p);
+        assert(f.sgetc() == 'l');
+    }
+    std::remove("seekoff.dat");
+    {
+        wchar_t buf[10];
+        typedef std::filebuf::pos_type pos_type;
+        std::wfilebuf f;
+        f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
+        assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
+        assert(buf[0] == L'v');
+        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+        assert(p == 11);
+        assert(f.sgetc() == L'l');
+        f.pubseekoff(0, std::ios_base::beg);
+        assert(f.sgetc() == L'a');
+        f.pubseekoff(-1, std::ios_base::end);
+        assert(f.sgetc() == L'z');
+        assert(f.pubseekpos(p) == p);
+        assert(f.sgetc() == L'l');
+    }
+    std::remove("seekoff.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
new file mode 100644
index 0000000..e2e107a
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
@@ -0,0 +1 @@
+123456789
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..c704d45
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type underflow();
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT> base;
+    typedef typename base::char_type  char_type;
+    typedef typename base::int_type   int_type;
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == '1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == '1');
+        assert(f.egptr() - f.eback() == 9);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.pubsetbuf(0, 0));
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == '1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == '1');
+        assert(f.egptr() - f.eback() == 8);
+        f.gbump(8);
+        assert(f.sgetc() == '9');
+        assert(f.eback()[0] == '5');
+        assert(f.eback()[1] == '6');
+        assert(f.eback()[2] == '7');
+        assert(f.eback()[3] == '8');
+        assert(f.gptr() - f.eback() == 4);
+        assert(*f.gptr() == '9');
+        assert(f.egptr() - f.gptr() == 1);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 9);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.pubsetbuf(0, 0));
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 8);
+        f.gbump(8);
+        assert(f.sgetc() == L'9');
+        assert(f.eback()[0] == L'5');
+        assert(f.eback()[1] == L'6');
+        assert(f.eback()[2] == L'7');
+        assert(f.eback()[3] == L'8');
+        assert(f.gptr() - f.eback() == 4);
+        assert(*f.gptr() == L'9');
+        assert(f.egptr() - f.gptr() == 1);
+    }
+    {
+        test_buf<wchar_t> f;
+        f.pubimbue(std::locale("en_US.UTF-8"));
+        assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == 0x4E51);
+        assert(f.sbumpc() == 0x4E52);
+        assert(f.sbumpc() == 0x4E53);
+        assert(f.sbumpc() == -1);
+    }
+}    
diff --git a/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
new file mode 100644
index 0000000..ee7063e
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
@@ -0,0 +1 @@
+乑乒乓
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp b/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp
new file mode 100644
index 0000000..8c412c9
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+//     : public basic_streambuf<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_filebuf<char> >::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp b/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..9c247ba
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void swap(basic_fstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        fs1.swap(fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove("test1.dat");
+    std::remove("test2.dat");
+    {
+        std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
+                                                         | std::ios_base::trunc);
+        std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
+                                                         | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        fs1.swap(fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove("test1.dat");
+    std::remove("test2.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp b/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..8225391
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.assign/move_assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream& operator=(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc);
+        std::fstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        std::wfstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp b/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..178092e
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// template <class charT, class traits> 
+//   void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        swap(fs1, fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove("test1.dat");
+    std::remove("test2.dat");
+    {
+        std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
+                                                         | std::ios_base::trunc);
+        std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
+                                                         | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        swap(fs1, fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove("test1.dat");
+    std::remove("test2.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
new file mode 100644
index 0000000..7e9e478
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::fstream fs;
+    }
+    {
+        std::wfstream fs;
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
new file mode 100644
index 0000000..0690bb4
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc);
+        std::fstream fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
+                                                        | std::ios_base::trunc);
+        std::wfstream fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..fb884d0
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs("test.dat", std::ios_base::in | std::ios_base::out
+                                                      | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fs("test.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
new file mode 100644
index 0000000..ad7cf47
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs(std::string("test.dat"),
+                        std::ios_base::in | std::ios_base::out
+                                          | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fs(std::string("test.dat"),
+                         std::ios_base::in | std::ios_base::out
+                                           | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp b/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
new file mode 100644
index 0000000..e18daf5
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat", std::ios_base::out);
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    remove("test.dat");
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat", std::ios_base::out);
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp b/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..4ce6933
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.members/open_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat", std::ios_base::in | std::ios_base::out
+                                              | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat", std::ios_base::in | std::ios_base::out
+                                              | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp b/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..d0596c2
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.members/open_string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
+                                                           | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
+                                                           | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp b/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..5cc55af
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs;
+        assert(fs.rdbuf());
+    }
+    {
+        std::wfstream fs;
+        assert(fs.rdbuf());
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/fstream/types.pass.cpp b/test/input.output/file.streams/fstreams/fstream/types.pass.cpp
new file mode 100644
index 0000000..3184f56
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/fstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+//     : public basic_iostream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_fstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..0dd5479
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void swap(basic_ifstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs1("test.dat");
+        std::ifstream fs2("test2.dat");
+        fs1.swap(fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs1("test.dat");
+        std::wifstream fs2("test2.dat");
+        fs1.swap(fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..a8b371c
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream& operator=(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ifstream fso("test.dat");
+        std::ifstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fso("test.dat");
+        std::wifstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..f2e08bb
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// template <class charT, class traits> 
+//   void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs1("test.dat");
+        std::ifstream fs2("test2.dat");
+        swap(fs1, fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs1("test.dat");
+        std::wifstream fs2("test2.dat");
+        swap(fs1, fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.assign/test.dat b/test/input.output/file.streams/fstreams/ifstream.assign/test.dat
new file mode 100644
index 0000000..64064d3
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.assign/test.dat
@@ -0,0 +1 @@
+3.25
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat b/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat
new file mode 100644
index 0000000..958d30d
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat
@@ -0,0 +1 @@
+4.5
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
new file mode 100644
index 0000000..6b5fc3b
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::ifstream fs;
+    }
+    {
+        std::wifstream fs;
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
new file mode 100644
index 0000000..d75def0
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ifstream fso("test.dat");
+        std::ifstream fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fso("test.dat");
+        std::wifstream fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..57fc3ca
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.cons/pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::ifstream fs("test.dat", std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs("test.dat", std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
new file mode 100644
index 0000000..0162050
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::ifstream fs(std::string("test.dat"), std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs(std::string("test.dat"), std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.cons/test.dat b/test/input.output/file.streams/fstreams/ifstream.cons/test.dat
new file mode 100644
index 0000000..64064d3
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.cons/test.dat
@@ -0,0 +1 @@
+3.25
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
new file mode 100644
index 0000000..4d1777e
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..8f10350
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == 'a');
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == 'r');
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == L'a');
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == L'r');
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..a7604ba
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.members/open_string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == 'a');
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == 'r');
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == L'a');
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == L'r');
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp b/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..d32efa1
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs("test.dat");
+        std::filebuf* fb = fs.rdbuf();
+        assert(fb->sgetc() == 'r');
+    }
+    {
+        std::wifstream fs("test.dat");
+        std::wfilebuf* fb = fs.rdbuf();
+        assert(fb->sgetc() == L'r');
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ifstream.members/test.dat b/test/input.output/file.streams/fstreams/ifstream.members/test.dat
new file mode 100644
index 0000000..1d2f014
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream.members/test.dat
@@ -0,0 +1 @@
+r
\ No newline at end of file
diff --git a/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp b/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp
new file mode 100644
index 0000000..6a431ba
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+//     : public basic_istream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_ifstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..fad2675
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void swap(basic_ofstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs1("test1.dat");
+        std::ofstream fs2("test2.dat");
+        fs1 << 3.25;
+        fs2 << 4.5;
+        fs1.swap(fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::ifstream fs("test1.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    remove("test1.dat");
+    {
+        std::ifstream fs("test2.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test2.dat");
+    {
+        std::wofstream fs1("test1.dat");
+        std::wofstream fs2("test2.dat");
+        fs1 << 3.25;
+        fs2 << 4.5;
+        fs1.swap(fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::wifstream fs("test1.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    remove("test1.dat");
+    {
+        std::wifstream fs("test2.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test2.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..7ee8150
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream& operator=(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ofstream fso("test.dat");
+        std::ofstream fs;
+        fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+    {
+        std::wofstream fso("test.dat");
+        std::wofstream fs;
+        fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..f256da9
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// template <class charT, class traits> 
+//   void swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs1("test1.dat");
+        std::ofstream fs2("test2.dat");
+        fs1 << 3.25;
+        fs2 << 4.5;
+        swap(fs1, fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::ifstream fs("test1.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    remove("test1.dat");
+    {
+        std::ifstream fs("test2.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test2.dat");
+    {
+        std::wofstream fs1("test1.dat");
+        std::wofstream fs2("test2.dat");
+        fs1 << 3.25;
+        fs2 << 4.5;
+        swap(fs1, fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::wifstream fs("test1.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    remove("test1.dat");
+    {
+        std::wifstream fs("test2.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test2.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
new file mode 100644
index 0000000..f66c9c0
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::ofstream fs;
+    }
+    {
+        std::wofstream fs;
+    }
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
new file mode 100644
index 0000000..5bd5a2a
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ofstream fso("test.dat");
+        std::ofstream fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+    {
+        std::wofstream fso("test.dat");
+        std::wofstream fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+#endif
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..ecbe065
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.cons/pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs("test.dat");
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs("test.dat");
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
new file mode 100644
index 0000000..a6a5a60
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs(std::string("test.dat"));
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs(std::string("test.dat"));
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
new file mode 100644
index 0000000..439b695
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..ec4b444
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::ifstream fs("test.dat");
+        char c = 0;
+        fs >> c;
+        assert(c == 'a');
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::wifstream fs("test.dat");
+        wchar_t c = 0;
+        fs >> c;
+        assert(c == L'a');
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..c1e2150
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.members/open_string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::ifstream fs("test.dat");
+        char c = 0;
+        fs >> c;
+        assert(c == 'a');
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::wifstream fs("test.dat");
+        wchar_t c = 0;
+        fs >> c;
+        assert(c == L'a');
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp b/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..0b95560
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream fs("test.dat");
+        std::filebuf* fb = fs.rdbuf();
+        assert(fb->sputc('r') == 'r');
+    }
+    remove("test.dat");
+    {
+        std::wofstream fs("test.dat");
+        std::wfilebuf* fb = fs.rdbuf();
+        assert(fb->sputc(L'r') == L'r');
+    }
+    remove("test.dat");
+}
diff --git a/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp b/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp
new file mode 100644
index 0000000..32b4643
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+//     : public basic_ostream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ofstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/file.streams/fstreams/version.pass.cpp b/test/input.output/file.streams/fstreams/version.pass.cpp
new file mode 100644
index 0000000..ed34b5a
--- /dev/null
+++ b/test/input.output/file.streams/fstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+#include <fstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/file.streams/nothing_to_do.pass.cpp b/test/input.output/file.streams/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/file.streams/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/input.output.general/nothing_to_do.pass.cpp b/test/input.output/input.output.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/input.output.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/ext.manip/get_money.pass.cpp b/test/input.output/iostream.format/ext.manip/get_money.pass.cpp
new file mode 100644
index 0000000..80dc0ed
--- /dev/null
+++ b/test/input.output/iostream.format/ext.manip/get_money.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  -$1,234,567.89");
+        std::istream is(&sb);
+        is.imbue(std::locale("en_US"));
+        long double x = 0;
+        is >> std::get_money(x, false);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<char> sb("  -USD 1,234,567.89");
+        std::istream is(&sb);
+        is.imbue(std::locale("en_US"));
+        long double x = 0;
+        is >> std::get_money(x, true);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<wchar_t> sb(L"  -$1,234,567.89");
+        std::wistream is(&sb);
+        is.imbue(std::locale("en_US"));
+        long double x = 0;
+        is >> std::get_money(x, false);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<wchar_t> sb(L"  -USD 1,234,567.89");
+        std::wistream is(&sb);
+        is.imbue(std::locale("en_US"));
+        long double x = 0;
+        is >> std::get_money(x, true);
+        assert(x == -123456789);
+    }
+}
diff --git a/test/input.output/iostream.format/ext.manip/get_time.pass.cpp b/test/input.output/iostream.format/ext.manip/get_time.pass.cpp
new file mode 100644
index 0000000..8a52bf3
--- /dev/null
+++ b/test/input.output/iostream.format/ext.manip/get_time.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  Sat Dec 31 23:55:59 2061");
+        std::istream is(&sb);
+        is.imbue(std::locale("en_US"));
+        std::tm t = {0};
+        is >> std::get_time(&t, "%c");
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L"  Sat Dec 31 23:55:59 2061");
+        std::wistream is(&sb);
+        is.imbue(std::locale("en_US"));
+        std::tm t = {0};
+        is >> std::get_time(&t, L"%c");
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/ext.manip/put_money.pass.cpp b/test/input.output/iostream.format/ext.manip/put_money.pass.cpp
new file mode 100644
index 0000000..ade9fb7
--- /dev/null
+++ b/test/input.output/iostream.format/ext.manip/put_money.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, false);
+        assert(sb.str() == "-$1,234,567.89");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, true);
+        assert(sb.str() == "-USD 1,234,567.89");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, false);
+        assert(sb.str() == L"-$1,234,567.89");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, true);
+        assert(sb.str() == L"-USD 1,234,567.89");
+    }
+}
diff --git a/test/input.output/iostream.format/ext.manip/put_time.pass.cpp b/test/input.output/iostream.format/ext.manip/put_time.pass.cpp
new file mode 100644
index 0000000..304b516
--- /dev/null
+++ b/test/input.output/iostream.format/ext.manip/put_time.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        std::tm t = {0};
+        t.tm_sec = 59;
+        t.tm_min = 55;
+        t.tm_hour = 23;
+        t.tm_mday = 31;
+        t.tm_mon = 11;
+        t.tm_year = 161;
+        t.tm_wday = 6;
+        os << std::put_time(&t, "%c");
+        assert(sb.str() == "Sat Dec 31 23:55:59 2061");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale("en_US"));
+        std::tm t = {0};
+        t.tm_sec = 59;
+        t.tm_min = 55;
+        t.tm_hour = 23;
+        t.tm_mday = 31;
+        t.tm_mon = 11;
+        t.tm_year = 161;
+        t.tm_wday = 6;
+        os << std::put_time(&t, L"%c");
+        assert(sb.str() == L"Sat Dec 31 23:55:59 2061");
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..076d399
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// void swap(basic_iostream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_iostream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_iostream<char> is1(&sb1);
+        test_iostream<char> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_iostream<wchar_t> is1(&sb1);
+        test_iostream<wchar_t> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..1b3fda7
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream& operator=(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_iostream& operator=(test_iostream&& s) 
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_iostream<char> is1(&sb1);
+        test_iostream<char> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_iostream<wchar_t> is1(&sb1);
+        test_iostream<wchar_t> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
new file mode 100644
index 0000000..7c1549a
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_iostream(test_iostream&& s) 
+        : base(std::move(s)) {}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb;
+        test_iostream<char> is1(&sb);
+        test_iostream<char> is(std::move(is1));
+        assert(is1.rdbuf() == &sb);
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_iostream<wchar_t> is1(&sb);
+        test_iostream<wchar_t> is(std::move(is1));
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is1.rdbuf() == &sb);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..7d087b3
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// explicit basic_iostream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_iostream<char> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_iostream<wchar_t> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp b/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp
new file mode 100644
index 0000000..e41cf76
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/iostreamclass/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream :
+//     public basic_istream<charT,traits>,
+//     public basic_ostream<charT,traits>
+// {
+// public:
+//     // types:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), "");
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
new file mode 100644
index 0000000..f1a234f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(bool& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        bool n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        bool n = true;
+        is >> n;
+        assert(n == false);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 1 ");
+        std::istream is(&sb);
+        bool n = 0;
+        is >> n;
+        assert(n == true);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 1 ");
+        std::wistream is(&sb);
+        bool n = 0;
+        is >> n;
+        assert(n == true);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
new file mode 100644
index 0000000..56414e9
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        double n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
new file mode 100644
index 0000000..9e4cc27
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(float& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        float n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
new file mode 100644
index 0000000..49ade23
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        int n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -1234567890123456 ");
+        std::wistream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == std::numeric_limits<int>::min());
+        assert(!is.eof());
+        assert( is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
new file mode 100644
index 0000000..03b86f9
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123 ");
+        std::wistream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == -123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
new file mode 100644
index 0000000..60ba96f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long double n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
new file mode 100644
index 0000000..ae0ea8d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123 ");
+        std::wistream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == -123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
new file mode 100644
index 0000000..0c10e27
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(void*& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        void* n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        void* n = (void*)1;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 1 ");
+        std::istream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)1);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 1 ");
+        std::wistream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)1);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
new file mode 100644
index 0000000..482b09f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        short n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -1234567890 ");
+        std::wistream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == std::numeric_limits<short>::min());
+        assert(!is.eof());
+        assert( is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 0000000..9fa8e8d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned int n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 0000000..08e2b70
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..7504b62
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned long long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 0000000..a095e53
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned short n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp
new file mode 100644
index 0000000..62121ed
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/basic_ios.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>&
+//                                         (*pf)(basic_ios<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.pass.cpp
new file mode 100644
index 0000000..74cd9cc
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/chart.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits> 
+//   basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+    {
+        testbuf<wchar_t> sb(L"   abc");
+        std::wistream is(&sb);
+        wchar_t c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        is >> c;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.pass.cpp
new file mode 100644
index 0000000..37fd2c3
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/ios_base.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+std::ios_base&
+f(std::ios_base& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp
new file mode 100644
index 0000000..bbaccb5
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/istream.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&
+//                                         (*pf)(basic_istream<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_istream<CharT>&
+f(std::basic_istream<CharT>& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp
new file mode 100644
index 0000000..6f7050d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits> 
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        signed char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        signed char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp
new file mode 100644
index 0000000..8a100f2
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/signed_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits> 
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        signed char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        is.width(4);
+        signed char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        signed char s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        signed char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string((char*)s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.pass.cpp
new file mode 100644
index 0000000..65b7a3e
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/streambuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is >> &sb2;
+        assert(sb2.str() == "testing...");
+        assert(is.gcount() == 10);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp
new file mode 100644
index 0000000..ce1792d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits> 
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        unsigned char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        unsigned char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp
new file mode 100644
index 0000000..5df4e8d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits> 
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        is.width(4);
+        unsigned char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string((char*)s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp
new file mode 100644
index 0000000..3b5dca6
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/istream::extractors/wchar_t_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits> 
+//   basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "abcdefghijk");
+    }
+    {
+        testbuf<wchar_t> sb(L"   abcdefghijk    ");
+        std::wistream is(&sb);
+        is.width(4);
+        wchar_t s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L"   abcdefghijk");
+        std::wistream is(&sb);
+        wchar_t s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp b/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp b/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
new file mode 100644
index 0000000..0820470
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits> 
+//   basic_istream<charT,traits>&
+//   ws(basic_istream<charT,traits>& is);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        ws(is);
+        assert(is.good());
+        assert(is.peek() == '1');
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        ws(is);
+        assert(is.good());
+        assert(is.peek() == L'1');
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
new file mode 100644
index 0000000..13a62ab
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits, class T> 
+//   basic_istream<charT, traits>& 
+//   operator>>(basic_istream<charT, traits>&& is, T& x);
+
+#include <istream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb("   123");
+        int i = 0;
+        std::istream(&sb) >> i;
+        assert(i == 123);
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        int i = 0;
+        std::wistream(&sb) >> i;
+        assert(i == 123);
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
new file mode 100644
index 0000000..b33813a
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type get();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<char> sb(" abc");
+        std::istream is(&sb);
+        char c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert( is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" abc");
+        std::wistream is(&sb);
+        wchar_t c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L' ');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert( is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
new file mode 100644
index 0000000..b90708c
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<char> sb(" abc");
+        std::istream is(&sb);
+        char c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" abc");
+        std::wistream is(&sb);
+        wchar_t c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L' ');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
new file mode 100644
index 0000000..a9751af
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  \n    \n ");
+        std::istream is(&sb);
+        char s[5];
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5);
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == '\n');
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == '\n');
+        is.get(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  \n    \n ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5);
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::wstring(s) == L"");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == L'\n');
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == L'\n');
+        is.get(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
new file mode 100644
index 0000000..f02c720
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  *    * ");
+        std::istream is(&sb);
+        char s[5];
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == '*');
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == '*');
+        is.get(s, 5, '*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  *    * ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::wstring(s) == L"");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == L'*');
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == L'*');
+        is.get(s, 5, L'*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
new file mode 100644
index 0000000..88345a5
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb); 
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing\n...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is.get(sb2);
+        assert(sb2.str() == "testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == '\n');
+        is.get(sb2);
+        assert(sb2.str() == "testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"testing\n...");
+        std::wistream is(&sb);
+        testbuf<wchar_t> sb2;
+        is.get(sb2);
+        assert(sb2.str() == L"testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == L'\n');
+        is.get(sb2);
+        assert(sb2.str() == L"testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
new file mode 100644
index 0000000..c1fd333
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb, 
+//                                  char_type delim); 
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing*...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is.get(sb2, '*');
+        assert(sb2.str() == "testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == '*');
+        is.get(sb2, '*');
+        assert(sb2.str() == "testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"testing*...");
+        std::wistream is(&sb);
+        testbuf<wchar_t> sb2;
+        is.get(sb2, L'*');
+        assert(sb2.str() == L"testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == L'*');
+        is.get(sb2, L'*');
+        assert(sb2.str() == L"testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
new file mode 100644
index 0000000..2d83491
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  \n    \n ");
+        std::istream is(&sb);
+        char s[5];
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  \n    \n ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
new file mode 100644
index 0000000..800b31c
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  *    * ");
+        std::istream is(&sb);
+        char s[5];
+        is.getline(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5, '*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  *    * ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.getline(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5, L'*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
new file mode 100644
index 0000000..6a31b6a
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& 
+//    ignore(streamsize n = 1, int_type delim = traits::eof());
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1\n2345\n6");
+        std::istream is(&sb);
+        is.ignore();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        is.ignore(5, '\n');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 2);
+        is.ignore(15);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 6);
+    }
+    {
+        testbuf<wchar_t> sb(L" 1\n2345\n6");
+        std::wistream is(&sb);
+        is.ignore();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        is.ignore(5, '\n');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 2);
+        is.ignore(15);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 6);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp
new file mode 100644
index 0000000..7051a76
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/peek.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type peek();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1\n2345\n6");
+        std::istream is(&sb);
+        assert(is.peek() == ' ');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+        is.get();
+        assert(is.peek() == '1');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 1\n2345\n6");
+        std::wistream is(&sb);
+        assert(is.peek() == L' ');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+        is.get();
+        assert(is.peek() == L'1');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
new file mode 100644
index 0000000..ec527c6
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& putback(char_type c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.putback('a');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+        is.clear();
+        is.putback('2');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback('1');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(' ');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(' ');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.putback(L'a');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+        is.clear();
+        is.putback(L'2');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L'1');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L' ');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L' ');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
new file mode 100644
index 0000000..f9487f6
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& read(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        char s[5];
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == " 1234");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == "56789");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert( is.fail());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L" 1234");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L"56789");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert( is.fail());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
new file mode 100644
index 0000000..3f55bef
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// streamsize readsome(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1234567890");
+        std::istream is(&sb);
+        char s[5];
+        assert(is.readsome(s, 5) == 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == " 1234");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == "56789");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        assert(std::string(s, 1) == "0");
+    }
+    {
+        testbuf<wchar_t> sb(L" 1234567890");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        assert(is.readsome(s, 5) == 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L" 1234");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L"56789");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        assert(std::wstring(s, 1) == L"0");
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
new file mode 100644
index 0000000..e99f1ab
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(pos_type pos);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekpos(typename base::pos_type sp,
+                                    std::ios_base::openmode which)
+    {
+        assert(which == std::ios_base::in);
+        return sp;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.seekg(5);
+        assert(is.good());
+        is.seekg(-1);
+        assert(is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.seekg(5);
+        assert(is.good());
+        is.seekg(-1);
+        assert(is.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
new file mode 100644
index 0000000..b185d5a
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir);
+
+#include <istream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekoff(typename base::off_type off,
+                                    std::ios_base::seekdir way,
+                                    std::ios_base::openmode which)
+    {
+        assert(which == std::ios_base::in);
+        ++seekoff_called;
+        return off;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.seekg(5, std::ios_base::cur);
+        assert(is.good());
+        assert(seekoff_called == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.seekg(5, std::ios_base::cur);
+        assert(is.good());
+        assert(seekoff_called == 2);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
new file mode 100644
index 0000000..9e19c0f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int sync();
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+
+protected:
+    int sync()
+    {
+        ++sync_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        assert(is.sync() == 0);
+        assert(sync_called = 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        assert(is.sync() == 0);
+        assert(sync_called = 2);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
new file mode 100644
index 0000000..4424a95
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// pos_type tellg();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekoff(typename base::off_type off,
+                                    std::ios_base::seekdir way,
+                                    std::ios_base::openmode which)
+    {
+        assert(off == 0);
+        assert(way == std::ios_base::cur);
+        assert(which == std::ios_base::in);
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        assert(is.tellg() == 5);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        assert(is.tellg() == 5);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp b/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
new file mode 100644
index 0000000..2d0eb1f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& unget();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp b/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..2961ecb
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// void swap(basic_istream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_istream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_istream<char> is1(&sb1);
+        test_istream<char> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_istream<wchar_t> is1(&sb1);
+        test_istream<wchar_t> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp b/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..41748f3
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream& operator=(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_istream& operator=(test_istream&& s)
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_istream<char> is1(&sb1);
+        test_istream<char> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_istream<wchar_t> is1(&sb1);
+        test_istream<wchar_t> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp b/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
new file mode 100644
index 0000000..f49deed
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_istream(test_istream&& s)
+        : base(std::move(s)) {}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb;
+        test_istream<char> is1(&sb);
+        test_istream<char> is(std::move(is1));
+        assert(is1.rdbuf() == &sb);
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_istream<wchar_t> is1(&sb);
+        test_istream<wchar_t> is(std::move(is1));
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is1.rdbuf() == &sb);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp b/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..0b0dc8d
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// explicit basic_istream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_istream<char> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_istream<wchar_t> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp b/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp
new file mode 100644
index 0000000..dcd760f
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/istream::sentry/ctor.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream::sentry;
+
+// explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::istream is((testbuf<char>*)0);
+        std::istream::sentry sen(is, true);
+        assert(!(bool)sen);
+        assert(!is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+    }
+    {
+        std::wistream is((testbuf<wchar_t>*)0);
+        std::wistream::sentry sen(is, true);
+        assert(!(bool)sen);
+        assert(!is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+    }
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        std::istream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        std::wistream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        std::istream::sentry sen(is);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        std::wistream::sentry sen(is);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 3);
+    }
+    {
+        testbuf<char> sb("      ");
+        std::istream is(&sb);
+        std::istream::sentry sen(is);
+        assert(!(bool)sen);
+        assert(is.fail());
+        assert(is.eof());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 6);
+    }
+    {
+        testbuf<char> sb("      ");
+        std::istream is(&sb);
+        std::istream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+}
diff --git a/test/input.output/iostream.format/input.streams/istream/types.pass.cpp b/test/input.output/iostream.format/input.streams/istream/types.pass.cpp
new file mode 100644
index 0000000..d9d471e
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/istream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream
+//     : virtual public basic_ios<charT,traits>
+// {
+// public:
+//     // types (inherited from basic_ios (27.5.4)):
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ios<char>, std::basic_istream<char> >::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/iostream.format/input.streams/version.pass.cpp b/test/input.output/iostream.format/input.streams/version.pass.cpp
new file mode 100644
index 0000000..9ad9c66
--- /dev/null
+++ b/test/input.output/iostream.format/input.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+#include <istream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/nothing_to_do.pass.cpp b/test/input.output/iostream.format/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..691fddd
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// void swap(basic_ostream& rhs);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_ostream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_ostream<char> os1(&sb1);
+        test_ostream<char> os2(&sb2);
+        os1.swap(os2);
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_ostream<wchar_t> os1(&sb1);
+        test_ostream<wchar_t> os2(&sb2);
+        os1.swap(os2);
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..0b78da4
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream& operator=(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_ostream& operator=(test_ostream&& s)
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_ostream<char> os1(&sb1);
+        test_ostream<char> os2(&sb2);
+        os2 = (std::move(os1));
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_ostream<wchar_t> os1(&sb1);
+        test_ostream<wchar_t> os2(&sb2);
+        os2 = (std::move(os1));
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
new file mode 100644
index 0000000..d7444a0
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_ostream(test_ostream&& s)
+        : base(std::move(s)) {}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb;
+        test_ostream<char> os1(&sb);
+        test_ostream<char> os(std::move(os1));
+        assert(os1.rdbuf() == &sb);
+        assert(os.rdbuf() == 0);
+        assert(os.tie() == 0);
+        assert(os.fill() == ' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_ostream<wchar_t> os1(&sb);
+        test_ostream<wchar_t> os(std::move(os1));
+        assert(os1.rdbuf() == &sb);
+        assert(os.rdbuf() == 0);
+        assert(os.tie() == 0);
+        assert(os.fill() == L' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..74a31af
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// explicit basic_ostream(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_ostream<char> os(&sb);
+        assert(os.rdbuf() == &sb);
+        assert(os.tie() == 0);
+        assert(os.fill() == ' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_ostream<wchar_t> os(&sb);
+        assert(os.rdbuf() == &sb);
+        assert(os.tie() == 0);
+        assert(os.fill() == L' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
new file mode 100644
index 0000000..e7e7504
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(bool val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        bool b = false;
+        os << b;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        bool b = false;
+        os << b;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        bool b = true;
+        os << b;
+        assert(sb.str() == "1");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        boolalpha(os);
+        bool b = true;
+        os << b;
+        assert(sb.str() == "true");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        boolalpha(os);
+        bool b = false;
+        os << b;
+        assert(sb.str() == "false");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
new file mode 100644
index 0000000..c7882bc
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        double n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        double n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        double n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        double n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
new file mode 100644
index 0000000..1b05f86
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(float val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        float n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        float n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        float n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        float n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
new file mode 100644
index 0000000..3464977
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        int n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        int n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        int n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        int n = -10;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
new file mode 100644
index 0000000..be4f643
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long n = 0xfffffff6;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
new file mode 100644
index 0000000..6d88290
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long double n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long double n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long double n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long double n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
new file mode 100644
index 0000000..47b6e4b
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long long n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long long n = -10;
+        os << n;
+        assert(sb.str() == "fffffffffffffff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
new file mode 100644
index 0000000..9282fbb
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(const void* val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const void* n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const void* n = 0;
+        os << n;
+        assert(sb.str() == "0x0");
+        assert(os.good());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const void* n = &sb;
+        os << n;
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
new file mode 100644
index 0000000..36ed10d
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        short n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        short n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        short n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        short n = -10;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 0000000..5907871
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned int n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned int n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned int n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned int n = 0xFFF6;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 0000000..9ee9f58
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned long n = 0xfffffff6;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..41ea650
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned long long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long long n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned long long n = -10;
+        os << n;
+        assert(sb.str() == "fffffffffffffff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 0000000..9f96e53
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned short n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned short n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned short n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned short n = 0xFFF6;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
new file mode 100644
index 0000000..f6aa56f
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits> 
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        wchar_t c = L'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"a");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
new file mode 100644
index 0000000..935ea39
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits> 
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const charT* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
new file mode 100644
index 0000000..26acb15
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
new file mode 100644
index 0000000..60a201c
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const char* c = "123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
new file mode 100644
index 0000000..5c4974e
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits> 
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"a");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
new file mode 100644
index 0000000..246ff93
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits> 
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const char* c = "123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
new file mode 100644
index 0000000..d777aa9
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, signed char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        signed char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
new file mode 100644
index 0000000..f432f05
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
new file mode 100644
index 0000000..be56928
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, unsigned char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
new file mode 100644
index 0000000..e8c5337
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits> 
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const unsigned char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
new file mode 100644
index 0000000..0d91b52
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>&
+//                                         (*pf)(basic_ios<charT,traits>&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& os)
+{
+    std::uppercase(os);
+    return os;
+}
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::uppercase));
+        os << f;
+        assert( (os.flags() & std::ios_base::uppercase));
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
new file mode 100644
index 0000000..9bdc2a7
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::uppercase));
+        os << std::uppercase;
+        assert( (os.flags() & std::ios_base::uppercase));
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp
new file mode 100644
index 0000000..c86bc0c
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<< 
+//           (basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&)) 
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+template <class CharT>
+std::basic_ostream<CharT>&
+f(std::basic_ostream<CharT>& os)
+{
+    os << "testing...";
+    return os;
+}
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << f;
+        assert(sb.str() == "testing...");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
new file mode 100644
index 0000000..b9acd19
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        testbuf<char> sb2("testing...");
+        assert(sb.str() == "");
+        os << &sb2;
+        assert(sb.str() == "testing...");
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
new file mode 100644
index 0000000..e532339
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits> 
+//   basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+
+    virtual int
+        sync()
+        {
+            ++sync_called;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        endl(os);
+        assert(sb.str() == "\n");
+        assert(sync_called == 1);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        endl(os);
+        assert(sb.str() == L"\n");
+        assert(sync_called == 2);
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
new file mode 100644
index 0000000..98308a0
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits> 
+//   basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        ends(os);
+        assert(sb.str().size() == 1);
+        assert(sb.str().back() == 0);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        ends(os);
+        assert(sb.str().size() == 1);
+        assert(sb.str().back() == 0);
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
new file mode 100644
index 0000000..2a14f8e
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits> 
+//   basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+public:
+    testbuf()
+    {
+    }
+
+protected:
+
+    virtual int
+        sync()
+        {
+            ++sync_called;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        flush(os);
+        assert(sync_called == 1);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        flush(os);
+        assert(sync_called == 2);
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
new file mode 100644
index 0000000..85c589c
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits, class T> 
+//   basic_ostream<charT, traits>& 
+//   operator<<(basic_ostream<charT, traits>&& os, const T& x);
+
+#include <ostream>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        testbuf<char> sb;
+        std::ostream(&sb) << "testing...";
+        assert(sb.str() == "testing...");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream(&sb) << L"123";
+        assert(sb.str() == L"123");
+    }
+#endif
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
new file mode 100644
index 0000000..e45db83
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(pos_type pos);
+
+#include <ostream>
+#include <cassert>
+
+int seekpos_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type 
+    seekpos(typename base::pos_type sp, std::ios_base::openmode which)
+    {
+        ++seekpos_called;
+        assert(which == std::ios_base::out);
+        return sp;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(&os.seekp(5) == &os);
+        assert(seekpos_called == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(&os.seekp(10) == &os);
+        assert(seekpos_called == 1);
+        assert(os.good());
+        assert(&os.seekp(-1) == &os);
+        assert(seekpos_called == 2);
+        assert(os.fail());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
new file mode 100644
index 0000000..f3e4d01
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type 
+    seekoff(typename base::off_type off, std::ios_base::seekdir way,
+                                         std::ios_base::openmode which)
+    {
+        ++seekoff_called;
+        assert(way == std::ios_base::beg);
+        assert(which == std::ios_base::out);
+        return off;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(&os.seekp(5, std::ios_base::beg) == &os);
+        assert(seekoff_called == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(&os.seekp(10, std::ios_base::beg) == &os);
+        assert(seekoff_called == 1);
+        assert(os.good());
+        assert(&os.seekp(-1, std::ios_base::beg) == &os);
+        assert(seekoff_called == 2);
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
new file mode 100644
index 0000000..bd35611
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// pos_type tellp();
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type 
+    seekoff(typename base::off_type off, std::ios_base::seekdir way, std::ios_base::openmode which)
+    {
+        assert(off == 0);
+        assert(way == std::ios_base::cur);
+        assert(which == std::ios_base::out);
+        ++seekoff_called;
+        return 10;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(os.tellp() == -1);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(os.tellp() == 10);
+        assert(seekoff_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
new file mode 100644
index 0000000..dcbdc4f
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream& flush();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+public:
+    testbuf()
+    {
+    }
+
+protected:
+
+    virtual int
+        sync()
+        {
+            if (sync_called++ == 1)
+                return -1;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.flush();
+        assert(os.good());
+        assert(sync_called == 1);
+        os.flush();
+        assert(os.bad());
+        assert(sync_called == 2);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
new file mode 100644
index 0000000..fc31d18
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& put(char_type c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        wchar_t c = L'a';
+        os.put(c);
+        assert(os.bad());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        wchar_t c = L'a';
+        os.put(c);
+        assert(sb.str() == L"a");
+        assert(os.good());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        char c = 'a';
+        os.put(c);
+        assert(sb.str() == "a");
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp b/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
new file mode 100644
index 0000000..9c399ad
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream& write(const char_type* s, streamsize n);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const wchar_t s[] = L"123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(os.bad());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const wchar_t s[] = L"123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(os.good());
+        assert(sb.str() == s);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const char s[] = "123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(sb.str() == s);
+        assert(os.good());
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp b/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp
new file mode 100644
index 0000000..db05eb6
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream
+//     : virtual public basic_ios<charT,traits>
+// {
+// public:
+//     // types (inherited from basic_ios (27.5.4)):
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <ostream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ios<char>, std::basic_ostream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp b/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp
new file mode 100644
index 0000000..a949f62
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream::sentry/construct.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// explicit sentry(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+    : public std::basic_streambuf<CharT>
+{
+    testbuf1() {}
+
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        std::ostream::sentry s(os);
+        assert(!bool(s));
+    }
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+    }
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        testbuf1<char> sb2;
+        std::ostream os2(&sb2);
+        os.tie(&os2);
+        assert(sync_called == 0);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+        assert(sync_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp b/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp
new file mode 100644
index 0000000..a5f9bb3
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/ostream::sentry/destruct.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// ~sentry();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+    : public std::basic_streambuf<CharT>
+{
+    testbuf1() {}
+
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        std::ostream::sentry s(os);
+        assert(!bool(s));
+    }
+    assert(sync_called == 0);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+    }
+    assert(sync_called == 0);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+        unitbuf(os);
+    }
+    assert(sync_called == 1);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        try
+        {
+            std::ostream::sentry s(os);
+            assert(bool(s));
+            unitbuf(os);
+            throw 1;
+        }
+        catch (...)
+        {
+        }
+        assert(sync_called == 1);
+    }
+}
diff --git a/test/input.output/iostream.format/output.streams/version.pass.cpp b/test/input.output/iostream.format/output.streams/version.pass.cpp
new file mode 100644
index 0000000..c43ff79
--- /dev/null
+++ b/test/input.output/iostream.format/output.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+#include <ostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp b/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
new file mode 100644
index 0000000..7a83cd8
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T1 resetiosflags(ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        assert(is.flags() & std::ios_base::skipws);
+        is >> std::resetiosflags(std::ios_base::skipws);
+        assert(!(is.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(os.flags() & std::ios_base::skipws);
+        os << std::resetiosflags(std::ios_base::skipws);
+        assert(!(os.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        assert(is.flags() & std::ios_base::skipws);
+        is >> std::resetiosflags(std::ios_base::skipws);
+        assert(!(is.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        assert(os.flags() & std::ios_base::skipws);
+        os << std::resetiosflags(std::ios_base::skipws);
+        assert(!(os.flags() & std::ios_base::skipws));
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/setbase.pass.cpp b/test/input.output/iostream.format/std.manip/setbase.pass.cpp
new file mode 100644
index 0000000..995bfdd
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/setbase.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T3 setbase(int base);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setbase(8);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        is >> std::setbase(10);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        is >> std::setbase(16);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        is >> std::setbase(15);
+        assert((is.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setbase(8);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        os << std::setbase(10);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        os << std::setbase(16);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        os << std::setbase(15);
+        assert((os.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setbase(8);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        is >> std::setbase(10);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        is >> std::setbase(16);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        is >> std::setbase(15);
+        assert((is.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setbase(8);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        os << std::setbase(10);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        os << std::setbase(16);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        os << std::setbase(15);
+        assert((os.flags() & std::ios_base::basefield) == 0);
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/setfill.pass.cpp b/test/input.output/iostream.format/std.manip/setfill.pass.cpp
new file mode 100644
index 0000000..654bd8b
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/setfill.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template<charT> T4 setfill(charT c);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setfill('*');
+        assert(os.fill() == '*');
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setfill(L'*');
+        assert(os.fill() == L'*');
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp b/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp
new file mode 100644
index 0000000..027e187
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T2 setiosflags (ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        assert(!(is.flags() & std::ios_base::oct));
+        is >> std::setiosflags(std::ios_base::oct);
+        assert(is.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::oct));
+        os << std::setiosflags(std::ios_base::oct);
+        assert(os.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        assert(!(is.flags() & std::ios_base::oct));
+        is >> std::setiosflags(std::ios_base::oct);
+        assert(is.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        assert(!(os.flags() & std::ios_base::oct));
+        os << std::setiosflags(std::ios_base::oct);
+        assert(os.flags() & std::ios_base::oct);
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/setprecision.pass.cpp b/test/input.output/iostream.format/std.manip/setprecision.pass.cpp
new file mode 100644
index 0000000..626c162
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/setprecision.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T5 setprecision(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setprecision(10);
+        assert(is.precision() == 10);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setprecision(10);
+        assert(os.precision() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setprecision(10);
+        assert(is.precision() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setprecision(10);
+        assert(os.precision() == 10);
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/setw.pass.cpp b/test/input.output/iostream.format/std.manip/setw.pass.cpp
new file mode 100644
index 0000000..85df1a4
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/setw.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T6 setw(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setw(10);
+        assert(is.width() == 10);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setw(10);
+        assert(os.width() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setw(10);
+        assert(is.width() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setw(10);
+        assert(os.width() == 10);
+    }
+}
diff --git a/test/input.output/iostream.format/std.manip/version.pass.cpp b/test/input.output/iostream.format/std.manip/version.pass.cpp
new file mode 100644
index 0000000..233c6e6
--- /dev/null
+++ b/test/input.output/iostream.format/std.manip/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+#include <iomanip>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.forward/iosfwd.pass.cpp b/test/input.output/iostream.forward/iosfwd.pass.cpp
new file mode 100644
index 0000000..ede5ca9
--- /dev/null
+++ b/test/input.output/iostream.forward/iosfwd.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+#include <cwchar>  // for mbstate_t
+
+int main()
+{
+    {
+    std::char_traits<char>*               t1 = 0;
+    std::char_traits<wchar_t>*            t2 = 0;
+    std::char_traits<unsigned short>*     t3 = 0;
+    }
+    {
+    std::basic_ios<char>*                 t1 = 0;
+    std::basic_ios<wchar_t>*              t2 = 0;
+    std::basic_ios<unsigned short>*       t3 = 0;
+    }
+    {
+    std::basic_streambuf<char>*           t1 = 0;
+    std::basic_streambuf<wchar_t>*        t2 = 0;
+    std::basic_streambuf<unsigned short>* t3 = 0;
+    }
+    {
+    std::basic_istream<char>*             t1 = 0;
+    std::basic_istream<wchar_t>*          t2 = 0;
+    std::basic_istream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ostream<char>*             t1 = 0;
+    std::basic_ostream<wchar_t>*          t2 = 0;
+    std::basic_ostream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_iostream<char>*             t1 = 0;
+    std::basic_iostream<wchar_t>*          t2 = 0;
+    std::basic_iostream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_stringbuf<char>*             t1 = 0;
+    std::basic_stringbuf<wchar_t>*          t2 = 0;
+    std::basic_stringbuf<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_istringstream<char>*             t1 = 0;
+    std::basic_istringstream<wchar_t>*          t2 = 0;
+    std::basic_istringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ostringstream<char>*             t1 = 0;
+    std::basic_ostringstream<wchar_t>*          t2 = 0;
+    std::basic_ostringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_stringstream<char>*             t1 = 0;
+    std::basic_stringstream<wchar_t>*          t2 = 0;
+    std::basic_stringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_filebuf<char>*             t1 = 0;
+    std::basic_filebuf<wchar_t>*          t2 = 0;
+    std::basic_filebuf<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ifstream<char>*             t1 = 0;
+    std::basic_ifstream<wchar_t>*          t2 = 0;
+    std::basic_ifstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ofstream<char>*             t1 = 0;
+    std::basic_ofstream<wchar_t>*          t2 = 0;
+    std::basic_ofstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_fstream<char>*             t1 = 0;
+    std::basic_fstream<wchar_t>*          t2 = 0;
+    std::basic_fstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::istreambuf_iterator<char>*             t1 = 0;
+    std::istreambuf_iterator<wchar_t>*          t2 = 0;
+    std::istreambuf_iterator<unsigned short>*   t3 = 0;
+    }
+    {
+    std::ostreambuf_iterator<char>*             t1 = 0;
+    std::ostreambuf_iterator<wchar_t>*          t2 = 0;
+    std::ostreambuf_iterator<unsigned short>*   t3 = 0;
+    }
+    {
+    std::ios*           t1 = 0;
+    std::wios*          t2 = 0;
+    }
+    {
+    std::streambuf*        t1 = 0;
+    std::istream*          t2 = 0;
+    std::ostream*          t3 = 0;
+    std::iostream*         t4 = 0;
+    }
+    {
+    std::stringbuf*            t1 = 0;
+    std::istringstream*        t2 = 0;
+    std::ostringstream*        t3 = 0;
+    std::stringstream*         t4 = 0;
+    }
+    {
+    std::filebuf*         t1 = 0;
+    std::ifstream*        t2 = 0;
+    std::ofstream*        t3 = 0;
+    std::fstream*         t4 = 0;
+    }
+    {
+    std::wstreambuf*        t1 = 0;
+    std::wistream*          t2 = 0;
+    std::wostream*          t3 = 0;
+    std::wiostream*         t4 = 0;
+    }
+    {
+    std::wstringbuf*            t1 = 0;
+    std::wistringstream*        t2 = 0;
+    std::wostringstream*        t3 = 0;
+    std::wstringstream*         t4 = 0;
+    }
+    {
+    std::wfilebuf*         t1 = 0;
+    std::wifstream*        t2 = 0;
+    std::wofstream*        t3 = 0;
+    std::wfstream*         t4 = 0;
+    }
+    {
+    std::fpos<std::mbstate_t>*   t1 = 0;
+    std::streampos*              t2 = 0;
+    std::wstreampos*             t3 = 0;
+    }
+}
diff --git a/test/input.output/iostream.forward/version.pass.cpp b/test/input.output/iostream.forward/version.pass.cpp
new file mode 100644
index 0000000..ece6eb5
--- /dev/null
+++ b/test/input.output/iostream.forward/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp b/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
new file mode 100644
index 0000000..65925e2
--- /dev/null
+++ b/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::cerr << "Hello World!\n";
+#else
+    assert(std::cerr.tie() == &std::cout);
+    assert(std::cerr.flags() & std::ios_base::unitbuf);
+#endif
+}
diff --git a/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp b/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
new file mode 100644
index 0000000..5a5806c
--- /dev/null
+++ b/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::cout << "Hello World!\n";
+    int i;
+    std::cout << "Enter a number: ";
+    std::cin >> i;
+    std::cout << "The number is : " << i << '\n';
+#else
+    assert(std::cin.tie() == &std::cout);
+#endif
+}
diff --git a/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp b/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
new file mode 100644
index 0000000..7369323
--- /dev/null
+++ b/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream clog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::clog << "Hello World!\n";
+#else
+    (void)std::clog;
+#endif
+}
diff --git a/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp b/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
new file mode 100644
index 0000000..b93be29
--- /dev/null
+++ b/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::cout << "Hello World!\n";
+    int i;
+    std::cout << "Enter a number: ";
+    std::cin >> i;
+    std::cout << "The number is : " << i << '\n';
+#else
+    (void)std::cout;
+#endif
+}
diff --git a/test/input.output/iostream.objects/version.pass.cpp b/test/input.output/iostream.objects/version.pass.cpp
new file mode 100644
index 0000000..32138f8
--- /dev/null
+++ b/test/input.output/iostream.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+#include <iostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp b/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
new file mode 100644
index 0000000..ff5009c
--- /dev/null
+++ b/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::wcerr << L"Hello World!\n";
+#else
+    assert(std::wcerr.tie() == &std::wcout);
+    assert(std::wcerr.flags() & std::ios_base::unitbuf);
+#endif
+}
diff --git a/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp b/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
new file mode 100644
index 0000000..fce5bc9
--- /dev/null
+++ b/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::wcout << L"Hello World!\n";
+    int i;
+    std::wcout << L"Enter a number: ";
+    std::wcin >> i;
+    std::wcout << L"The number is : " << i << L'\n';
+#else
+    assert(std::wcin.tie() == &std::wcout);
+#endif
+}
diff --git a/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp b/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
new file mode 100644
index 0000000..b1405f5
--- /dev/null
+++ b/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wclog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::wclog << L"Hello World!\n";
+#else
+    (void)std::wclog;
+#endif
+}
diff --git a/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp b/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
new file mode 100644
index 0000000..aa6d384
--- /dev/null
+++ b/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::wcout << L"Hello World!\n";
+#else
+    (void)std::wcout;
+#endif
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
new file mode 100644
index 0000000..ccb1af4
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// void state(stateT s);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::fpos<int> f;
+    f.state(3);
+    assert(f.state() == 3);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
new file mode 100644
index 0000000..c720b08
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Addition
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    std::streamoff o(6);
+    P q = p + o;
+    assert(q == P(11));
+    p += o;
+    assert(p == q);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
new file mode 100644
index 0000000..8a23ff2
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// fpos(int)
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    assert(p == P(5));
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp
new file mode 100644
index 0000000..baefb93
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/difference.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with fpos
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(11);
+    P q(6);
+    std::streamoff o = p - q;
+    assert(o == 5);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp
new file mode 100644
index 0000000..c455769
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// == and !=
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    P q(6);
+    assert(p == p);
+    assert(p != q);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
new file mode 100644
index 0000000..9ae8073
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// converts to and from streamoff
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(std::streamoff(7));
+    std::streamoff offset(p);
+    assert(offset == 7);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
new file mode 100644
index 0000000..f662b72
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// streamsize and streamoff interconvert
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::streamoff o(5);
+    std::streamsize sz(o);
+    assert(sz == 5);
+    std::streamoff o2(sz);
+    assert(o == o2);
+}
diff --git a/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp b/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
new file mode 100644
index 0000000..7bc9ea8
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with offset
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(11);
+    std::streamoff o(6);
+    P q = p - o;
+    assert(q == P(5));
+    p -= o;
+    assert(p == q);
+}
diff --git a/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp b/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
new file mode 100644
index 0000000..685f4a6
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.flags() == (test::skipws | test::dec));
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp
new file mode 100644
index 0000000..d1e4915
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags(fmtflags fmtfl);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.flags(test::hex | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::hex | test::right));
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
new file mode 100644
index 0000000..13c4215
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.precision() == 6);
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp
new file mode 100644
index 0000000..a68ca12
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision(streamsize prec);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.precision() == 6);
+    std::streamsize p = t.precision(10);
+    assert(p == 6);
+    assert(t.precision() == 10);
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp
new file mode 100644
index 0000000..5584c8b
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl)
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.setf(test::hex | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::skipws | test::dec | test::hex | test::right));
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp
new file mode 100644
index 0000000..2ec8737
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl, fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.setf(test::hex | test::right, test::dec | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::skipws | test::right));
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
new file mode 100644
index 0000000..a45d557
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void unsetf(fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    t.unsetf(test::dec | test::right);
+    assert(t.flags() == test::skipws);
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
new file mode 100644
index 0000000..b578530
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.width() == 0);
+}
diff --git a/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp b/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp
new file mode 100644
index 0000000..c8a4488
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width(streamsize wide);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.width() == 0);
+    std::streamsize w = t.width(4);
+    assert(w == 0);
+    assert(t.width() == 4);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
new file mode 100644
index 0000000..33a37cd
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void register_callback(event_callback fn, int index);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int f1_called = 0;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 4);
+        ++f1_called;
+    }
+}
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    b.register_callback(f1, 4);
+    b.register_callback(f1, 4);
+    b.register_callback(f1, 4);
+    std::locale l = b.imbue(std::locale("en_US"));
+    assert(f1_called == 3);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
new file mode 100644
index 0000000..6c52995
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ~ios_base()
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    {
+        test t;
+        std::ios_base& b = t;
+        b.register_callback(f1, 4);
+        b.register_callback(f2, 5);
+        b.register_callback(f3, 6);
+    }
+    assert(f1_called);
+    assert(f2_called);
+    assert(f3_called);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
new file mode 100644
index 0000000..bd4d737
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale getloc() const;
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.getloc().name() == std::string("C"));
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp
new file mode 100644
index 0000000..01cc795
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    b.register_callback(f1, 4);
+    b.register_callback(f2, 5);
+    b.register_callback(f3, 6);
+    std::locale l = b.imbue(std::locale("en_US"));
+    assert(l.name() == std::string("C"));
+    assert(b.getloc().name() == std::string("en_US"));
+    assert(f1_called);
+    assert(f2_called);
+    assert(f3_called);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
new file mode 100644
index 0000000..e700c5a
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// long& iword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    for (int i = 0; i < 10000; ++i)
+    {
+        assert(b.iword(i) == 0);
+        b.iword(i) = i;
+        assert(b.iword(i) == i);
+        for (int j = 0; j <= i; ++j)
+            assert(b.iword(j) == j);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
new file mode 100644
index 0000000..a96e6e1
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void*& pword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    for (int i = 0; i < 10000; ++i)
+    {
+        assert(b.pword(i) == 0);
+        b.pword(i) = (void*)i;
+        assert(b.pword(i) == (void*)i);
+        for (int j = 0; j <= i; ++j)
+            assert(b.pword(j) == (void*)j);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp
new file mode 100644
index 0000000..3f803b2
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static int xalloc();
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::xalloc() == 0);
+    assert(std::ios_base::xalloc() == 1);
+    assert(std::ios_base::xalloc() == 2);
+    assert(std::ios_base::xalloc() == 3);
+    assert(std::ios_base::xalloc() == 4);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
new file mode 100644
index 0000000..71334fe
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// bool sync_with_stdio(bool sync = true);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert( std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio(true));
+    assert( std::ios_base::sync_with_stdio(true));
+    assert( std::ios_base::sync_with_stdio());
+    assert( std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio());
+    assert( std::ios_base::sync_with_stdio());
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::Init/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp
new file mode 100644
index 0000000..1d4b3cb
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_char_pointer_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const char* msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg.c_str(), make_error_code(std::errc::is_a_directory));
+        assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find("Is a directory") != std::string::npos);
+    }
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg.c_str());
+        assert(se.code() == std::make_error_code(std::io_errc::stream));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find(std::iostream_category().message(static_cast<int>
+            (std::io_errc::stream))) != std::string::npos);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp
new file mode 100644
index 0000000..7c6051f
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::failure/ctor_string_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const string& msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory));
+        assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find("Is a directory") != std::string::npos);
+    }
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg);
+        assert(se.code() == std::make_error_code(std::io_errc::stream));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find(std::iostream_category().message(static_cast<int>
+            (std::io_errc::stream))) != std::string::npos);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp
new file mode 100644
index 0000000..bf91c44
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::fmtflags/fmtflags.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const fmtflags boolalpha; 
+// static const fmtflags dec; 
+// static const fmtflags fixed; 
+// static const fmtflags hex; 
+// static const fmtflags internal; 
+// static const fmtflags left; 
+// static const fmtflags oct; 
+// static const fmtflags right; 
+// static const fmtflags scientific; 
+// static const fmtflags showbase; 
+// static const fmtflags showpoint; 
+// static const fmtflags showpos; 
+// static const fmtflags skipws; 
+// static const fmtflags unitbuf; 
+// static const fmtflags uppercase; 
+// static const fmtflags adjustfield = left | right | internal;
+// static const fmtflags basefield   = dec | oct | hex;
+// static const fmtflags floatfield  = scientific | fixed;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::boolalpha);
+    assert(std::ios_base::dec);
+    assert(std::ios_base::fixed);
+    assert(std::ios_base::hex);
+    assert(std::ios_base::internal);
+    assert(std::ios_base::left);
+    assert(std::ios_base::oct);
+    assert(std::ios_base::right);
+    assert(std::ios_base::scientific);
+    assert(std::ios_base::showbase);
+    assert(std::ios_base::showpoint);
+    assert(std::ios_base::showpos);
+    assert(std::ios_base::skipws);
+    assert(std::ios_base::unitbuf);
+    assert(std::ios_base::uppercase);
+
+    assert
+    (
+        ( std::ios_base::boolalpha
+        & std::ios_base::dec
+        & std::ios_base::fixed
+        & std::ios_base::hex
+        & std::ios_base::internal
+        & std::ios_base::left
+        & std::ios_base::oct
+        & std::ios_base::right
+        & std::ios_base::scientific
+        & std::ios_base::showbase
+        & std::ios_base::showpoint
+        & std::ios_base::showpos
+        & std::ios_base::skipws
+        & std::ios_base::unitbuf
+        & std::ios_base::uppercase) == 0
+    );
+
+    assert(std::ios_base::adjustfield == (std::ios_base::left
+                                        | std::ios_base::right
+                                        | std::ios_base::internal));
+    assert(std::ios_base::basefield == (std::ios_base::dec
+                                      | std::ios_base::oct
+                                      | std::ios_base::hex));
+    assert(std::ios_base::floatfield == (std::ios_base::scientific
+                                       | std::ios_base::fixed));
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.pass.cpp
new file mode 100644
index 0000000..4c73561
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::iostate/iostate.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const iostate badbit;
+// static const iostate eofbit; 
+// static const iostate failbit; 
+// static const iostate goodbit = 0;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::badbit);
+    assert(std::ios_base::eofbit);
+    assert(std::ios_base::failbit);
+
+    assert
+    (
+        ( std::ios_base::badbit
+        & std::ios_base::eofbit
+        & std::ios_base::failbit) == 0
+    );
+
+    assert(std::ios_base::goodbit == 0);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp
new file mode 100644
index 0000000..9a59271
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::openmode/openmode.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const openmode app;
+// static const openmode ate; 
+// static const openmode binary; 
+// static const openmode in; 
+// static const openmode out; 
+// static const openmode trunc; 
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::app);
+    assert(std::ios_base::ate);
+    assert(std::ios_base::binary);
+    assert(std::ios_base::in);
+    assert(std::ios_base::out);
+    assert(std::ios_base::trunc);
+
+    assert
+    (
+        ( std::ios_base::app
+        & std::ios_base::ate
+        & std::ios_base::binary
+        & std::ios_base::in
+        & std::ios_base::out
+        & std::ios_base::trunc) == 0
+    );
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.pass.cpp
new file mode 100644
index 0000000..5aeee65
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/ios::seekdir/seekdir.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const seekdir beg;
+// static const seekdir cur; 
+// static const seekdir end; 
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::beg != std::ios_base::cur);
+    assert(std::ios_base::beg != std::ios_base::end);
+    assert(std::ios_base::cur != std::ios_base::end);
+}
diff --git a/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp b/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp b/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..bcb85cf
--- /dev/null
+++ b/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp
new file mode 100644
index 0000000..771f115
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// explicit basic_ios(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    {
+        std::streambuf* sb = 0;
+        std::basic_ios<char> ios(sb);
+        assert(ios.rdbuf() == sb);
+        assert(ios.tie() == 0);
+        assert(ios.rdstate() == std::ios::badbit);
+        assert(ios.exceptions() == std::ios::goodbit);
+        assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+        assert(ios.width() == 0);
+        assert(ios.precision() == 6);
+        assert(ios.fill() == ' ');
+        assert(ios.getloc() == std::locale());
+    }
+    {
+        std::streambuf* sb = (std::streambuf*)1;
+        std::basic_ios<char> ios(sb);
+        assert(ios.rdbuf() == sb);
+        assert(ios.tie() == 0);
+        assert(ios.rdstate() == std::ios::goodbit);
+        assert(ios.exceptions() == std::ios::goodbit);
+        assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+        assert(ios.width() == 0);
+        assert(ios.precision() == 6);
+        assert(ios.fill() == ' ');
+        assert(ios.getloc() == std::locale());
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
new file mode 100644
index 0000000..dc1484d
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ios& copyfmt(const basic_ios& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert( g2_called);
+        assert( g3_called);
+        assert(stream.getloc().name() == "fr_FR");
+        assert(index == 7);
+        g1_called = true;
+    }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert( g3_called);
+        assert(stream.getloc().name() == "fr_FR");
+        assert(index == 8);
+        g2_called = true;
+    }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == "fr_FR");
+        assert(index == 9);
+        g3_called = true;
+    }
+}
+
+int main()
+{
+    testbuf sb1;
+    std::ios ios1(&sb1);
+    ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+    ios1.precision(1);
+    ios1.width(11);
+    ios1.imbue(std::locale("en_US"));
+    ios1.exceptions(std::ios::failbit);
+    ios1.setstate(std::ios::eofbit);
+    ios1.register_callback(f1, 4);
+    ios1.register_callback(f2, 5);
+    ios1.iword(0) = 1;
+    ios1.iword(1) = 2;
+    ios1.iword(2) = 3;
+    char c1, c2, c3;
+    ios1.pword(0) = &c1;
+    ios1.pword(1) = &c2;
+    ios1.pword(2) = &c3;
+    ios1.tie((std::ostream*)1);
+    ios1.fill('1');
+
+    testbuf sb2;
+    std::ios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale("fr_FR"));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.copyfmt(ios1);
+    assert(!f1_called);
+
+    try
+    {
+        ios1.copyfmt(ios2);
+        assert(false);
+    }
+    catch (std::ios_base::failure&)
+    {
+    }
+    assert(ios1.rdstate() == std::ios::eofbit);
+    assert(ios1.rdbuf() == &sb1);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == "fr_FR");
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(f1_called);
+    assert(f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
new file mode 100644
index 0000000..57ec94e
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.fill() == ' ');
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
new file mode 100644
index 0000000..8b09684
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill(char_type fillch);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.fill() == ' ');
+    char c = ios.fill('*');
+    assert(c == ' ');
+    assert(ios.fill() == '*');
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
new file mode 100644
index 0000000..dd1d416
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == "en_US");
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.register_callback(f1, 4);
+        ios.register_callback(f2, 5);
+        ios.register_callback(f3, 6);
+        std::locale l = ios.imbue(std::locale("en_US"));
+        assert(l.name() == std::string("C"));
+        assert(ios.getloc().name() == std::string("en_US"));
+        assert(f1_called);
+        assert(f2_called);
+        assert(f3_called);
+    }
+    f1_called = false;
+    f2_called = false;
+    f3_called = false;
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.register_callback(f1, 4);
+        ios.register_callback(f2, 5);
+        ios.register_callback(f3, 6);
+        std::locale l = ios.imbue(std::locale("en_US"));
+        assert(l.name() == std::string("C"));
+        assert(ios.getloc().name() == std::string("en_US"));
+        assert(sb.getloc().name() == std::string("en_US"));
+        assert(f1_called);
+        assert(f2_called);
+        assert(f3_called);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
new file mode 100644
index 0000000..a50f2d9
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios() {}
+    testios(std::streambuf* p) : std::ios(p) {}
+    void move(std::ios& x) {std::ios::move(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 7);
+        g1_called = true;
+    }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 8);
+        g2_called = true;
+    }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 9);
+        g3_called = true;
+    }
+}
+
+int main()
+{
+    testios ios1;
+    testbuf sb2;
+    std::ios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale("fr_FR"));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.move(ios2);
+
+    assert(ios1.rdstate() == std::ios::goodbit);
+    assert(ios1.rdbuf() == 0);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == "fr_FR");
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(!g1_called);
+    assert(!g2_called);
+    assert(!g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+    ios1.imbue(std::locale("C"));
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+
+    assert(ios2.rdbuf() == &sb2);
+    assert(ios2.tie() == 0);
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
new file mode 100644
index 0000000..db23adb
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char narrow(char_type c, char dfault) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.narrow('c', '*') == 'c');
+    assert(ios.narrow('\xFE', '*') == '*');
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..1cf250a
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::ios ios(0);
+        assert(ios.rdbuf() == 0);
+    }
+    {
+        std::streambuf* sb = (std::streambuf*)1;
+        const std::ios ios(sb);
+        assert(ios.rdbuf() == sb);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
new file mode 100644
index 0000000..3dde3e5
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.rdbuf() == 0);
+    assert(!ios.good());
+    std::streambuf* sb = (std::streambuf*)1;
+    std::streambuf* sb2 = ios.rdbuf(sb);
+    assert(sb2 == 0);
+    assert(ios.rdbuf() == sb);
+    assert(ios.good());
+    sb2 = ios.rdbuf(0);
+    assert(sb2 == (std::streambuf*)1);
+    assert(ios.rdbuf() == 0);
+    assert(ios.bad());
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
new file mode 100644
index 0000000..2ce7a92
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void set_rdbuf(basic_streambuf<charT, traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios(std::streambuf* p) : std::ios(p) {}
+    void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);}
+};
+
+int main()
+{
+    testbuf sb1;
+    testbuf sb2;
+    testios ios(&sb1);
+    try
+    {
+        ios.setstate(std::ios::badbit);
+        ios.exceptions(std::ios::badbit);
+    }
+    catch (...)
+    {
+    }
+    ios.set_rdbuf(&sb2);
+    assert(ios.rdbuf() == &sb2);
+    try
+    {
+        ios.setstate(std::ios::badbit);
+        ios.exceptions(std::ios::badbit);
+    }
+    catch (...)
+    {
+    }
+    ios.set_rdbuf(0);
+    assert(ios.rdbuf() == 0);
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
new file mode 100644
index 0000000..bd49d5f
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios(std::streambuf* p) : std::ios(p) {}
+    void swap(std::ios& x) {std::ios::swap(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 4);
+    f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 5);
+    f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 7);
+    g1_called = true;
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 8);
+    g2_called = true;
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 9);
+    g3_called = true;
+}
+
+int main()
+{
+    testbuf sb1;
+    testios ios1(&sb1);
+    ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+    ios1.precision(1);
+    ios1.width(11);
+    ios1.imbue(std::locale("en_US"));
+    ios1.exceptions(std::ios::failbit);
+    ios1.setstate(std::ios::eofbit);
+    ios1.register_callback(f1, 4);
+    ios1.register_callback(f2, 5);
+    ios1.iword(0) = 1;
+    ios1.iword(1) = 2;
+    ios1.iword(2) = 3;
+    char c1, c2, c3;
+    ios1.pword(0) = &c1;
+    ios1.pword(1) = &c2;
+    ios1.pword(2) = &c3;
+    ios1.tie((std::ostream*)1);
+    ios1.fill('1');
+
+    testbuf sb2;
+    testios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale("fr_FR"));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.swap(ios2);
+
+    assert(ios1.rdstate() == std::ios::goodbit);
+    assert(ios1.rdbuf() == &sb1);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == "fr_FR");
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(!g1_called);
+    assert(!g2_called);
+    assert(!g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+    ios1.imbue(std::locale("C"));
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+
+    assert(ios2.rdstate() == std::ios::eofbit);
+    assert(ios2.rdbuf() == &sb2);
+    assert(ios2.flags() == (std::ios::boolalpha | std::ios::dec | std::ios::fixed));
+    assert(ios2.precision() == 1);
+    assert(ios2.width() == 11);
+    assert(ios2.getloc().name() == "en_US");
+    assert(ios2.exceptions() == std::ios::failbit);
+    assert(ios2.iword(0) == 1);
+    assert(ios2.iword(1) == 2);
+    assert(ios2.iword(2) == 3);
+    assert(ios2.pword(0) == &c1);
+    assert(ios2.pword(1) == &c2);
+    assert(ios2.pword(2) == &c3);
+    assert(ios2.tie() == (std::ostream*)1);
+    assert(ios2.fill() == '1');
+    ios2.imbue(std::locale("C"));
+    assert(f1_called);
+    assert(f2_called);
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
new file mode 100644
index 0000000..ef400ec
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::basic_ios<char> ios(0);
+    assert(ios.tie() == 0);
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp
new file mode 100644
index 0000000..7b3c043
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    std::ostream* os = (std::ostream*)1;
+    std::ostream* r = ios.tie(os);
+    assert(r == 0);
+    assert(ios.tie() == os);
+}
diff --git a/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
new file mode 100644
index 0000000..18e2cb5
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type widen(char c) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.widen('c') == 'c');
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
new file mode 100644
index 0000000..340b06b
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool bad() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.bad());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.bad());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.bad());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.bad());
+        ios.setstate(std::ios::failbit);
+        assert(!ios.bad());
+        ios.setstate(std::ios::badbit);
+        assert(ios.bad());
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
new file mode 100644
index 0000000..837f949
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// operator unspecified-bool-type() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(static_cast<bool>(ios) == !ios.fail());
+    ios.setstate(std::ios::failbit);
+    assert(static_cast<bool>(ios) == !ios.fail());
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
new file mode 100644
index 0000000..8d46f91
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void clear(iostate state = goodbit);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::badbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+        }
+        catch (...)
+        {
+        }
+        try
+        {
+            ios.clear();
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == std::ios::badbit);
+        }
+        try
+        {
+            ios.clear(std::ios::eofbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+        }
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.exceptions(std::ios::badbit);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.clear(std::ios::eofbit);
+        assert(ios.rdstate() == std::ios::eofbit);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp
new file mode 100644
index 0000000..3319e08
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/eof.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool eof() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(!ios.eof());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.eof());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.eof());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.eof());
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
new file mode 100644
index 0000000..0050e0c
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        const std::ios ios(0);
+        assert(ios.exceptions() == std::ios::goodbit);
+    }
+    {
+        testbuf sb;
+        const std::ios ios(&sb);
+        assert(ios.exceptions() == std::ios::goodbit);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
new file mode 100644
index 0000000..9a7904f
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.exceptions() == std::ios::goodbit);
+        ios.exceptions(std::ios::eofbit);
+        assert(ios.exceptions() == std::ios::eofbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+        }
+        assert(ios.exceptions() == std::ios::badbit);
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(ios.exceptions() == std::ios::goodbit);
+        ios.exceptions(std::ios::eofbit);
+        assert(ios.exceptions() == std::ios::eofbit);
+        ios.exceptions(std::ios::badbit);
+        assert(ios.exceptions() == std::ios::badbit);
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
new file mode 100644
index 0000000..b47e728
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool fail() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.fail());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.fail());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.fail());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.fail());
+        ios.setstate(std::ios::badbit);
+        assert(ios.fail());
+        ios.setstate(std::ios::failbit);
+        assert(ios.fail());
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
new file mode 100644
index 0000000..a01d449
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool good() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(!ios.good());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(ios.good());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.good());
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
new file mode 100644
index 0000000..0bf3ccc
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool operator!() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(!ios == ios.fail());
+    ios.setstate(std::ios::failbit);
+    assert(!ios == ios.fail());
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
new file mode 100644
index 0000000..3be5871
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate rdstate() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.rdstate() == std::ios::badbit);
+    ios.setstate(std::ios::failbit);
+    assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit));
+}
diff --git a/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
new file mode 100644
index 0000000..4b04542
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void setstate(iostate state);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.setstate(std::ios::goodbit);
+        assert(ios.rdstate() == std::ios::badbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+        }
+        catch (...)
+        {
+        }
+        try
+        {
+            ios.setstate(std::ios::goodbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == std::ios::badbit);
+        }
+        try
+        {
+            ios.setstate(std::ios::eofbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+        }
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.setstate(std::ios::goodbit);
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.setstate(std::ios::eofbit);
+        assert(ios.rdstate() == std::ios::eofbit);
+        ios.setstate(std::ios::failbit);
+        assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit));
+    }
+}
diff --git a/test/input.output/iostreams.base/ios/types.pass.cpp b/test/input.output/iostreams.base/ios/types.pass.cpp
new file mode 100644
index 0000000..0b9aeac
--- /dev/null
+++ b/test/input.output/iostreams.base/ios/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits = char_traits<charT> > 
+// class basic_ios : public ios_base
+// {
+// public:
+//     typedef charT char_type; 
+//     typedef typename traits::int_type int_type; 
+//     typedef typename traits::pos_type pos_type; 
+//     typedef typename traits::off_type off_type; 
+//     typedef traits traits_type; 
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
new file mode 100644
index 0000000..67eabb6
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& internal(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::internal(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::internal);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
new file mode 100644
index 0000000..3bf05c8
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& left(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::left(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::left);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
new file mode 100644
index 0000000..25ca737
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& right(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::right(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::right);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
new file mode 100644
index 0000000..74e114b
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& dec(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::dec(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::dec);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
new file mode 100644
index 0000000..c1ca0d6
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hex(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::hex(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::hex);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
new file mode 100644
index 0000000..6c020e7
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& oct(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::oct(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::oct);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
new file mode 100644
index 0000000..bfed3f4
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// const error_category& iostream_category();
+
+#include <ios>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::iostream_category();
+    std::string m1 = e_cat1.name();
+    assert(m1 == "iostream");
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
new file mode 100644
index 0000000..f404cb1
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_code make_error_code(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = make_error_code(std::io_errc::stream);
+        assert(ec.value() == static_cast<int>(std::io_errc::stream));
+        assert(ec.category() == std::iostream_category());
+    }
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
new file mode 100644
index 0000000..0024984
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_condition make_error_condition(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream);
+        assert(ec1.value() == static_cast<int>(std::io_errc::stream));
+        assert(ec1.category() == std::iostream_category());
+    }
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
new file mode 100644
index 0000000..3b8b967
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& defaultfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::defaultfloat(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::fixed));
+    assert(!(ios.flags() & std::ios::scientific));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
new file mode 100644
index 0000000..2b704e4
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& fixed(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::fixed(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::fixed);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
new file mode 100644
index 0000000..c849e86
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hexfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::hexfloat(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::fixed);
+    assert(ios.flags() & std::ios::scientific);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
new file mode 100644
index 0000000..e20e993
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& scientific(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::scientific(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::scientific);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
new file mode 100644
index 0000000..08734cf
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& boolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::boolalpha(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::boolalpha);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
new file mode 100644
index 0000000..4f31343
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noboolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::boolalpha(ios);
+    std::ios_base& r = std::noboolalpha(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::boolalpha));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
new file mode 100644
index 0000000..fe47b6c
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showbase(ios);
+    std::ios_base& r = std::noshowbase(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showbase));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
new file mode 100644
index 0000000..71cdc50
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showpoint(ios);
+    std::ios_base& r = std::noshowpoint(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showpoint));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
new file mode 100644
index 0000000..902506e
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showpos(ios);
+    std::ios_base& r = std::noshowpos(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showpos));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
new file mode 100644
index 0000000..2e2c3a6
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noskipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::skipws(ios);
+    std::ios_base& r = std::noskipws(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::skipws));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
new file mode 100644
index 0000000..ddfaee5
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nounitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::unitbuf(ios);
+    std::ios_base& r = std::nounitbuf(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::unitbuf));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
new file mode 100644
index 0000000..864dcc4
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nouppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::uppercase(ios);
+    std::ios_base& r = std::nouppercase(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::uppercase));
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
new file mode 100644
index 0000000..84fe15b
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showbase(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showbase);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
new file mode 100644
index 0000000..ce6ef8c
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showpoint(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showpoint);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
new file mode 100644
index 0000000..74665af
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showpos(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showpos);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
new file mode 100644
index 0000000..71c47f4
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& skipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::skipws(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::skipws);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
new file mode 100644
index 0000000..a931cc4
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& unitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::unitbuf(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::unitbuf);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
new file mode 100644
index 0000000..653bd1c
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& uppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::uppercase(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::uppercase);
+}
diff --git a/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp b/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp b/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp
new file mode 100644
index 0000000..85c1f5e
--- /dev/null
+++ b/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef OFF_T streamoff;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert(std::is_integral<std::streamoff>::value, "");
+    static_assert(std::is_signed<std::streamoff>::value, "");
+}
diff --git a/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp b/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp
new file mode 100644
index 0000000..0c31b16
--- /dev/null
+++ b/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef SZ_T streamsize;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert(std::is_integral<std::streamsize>::value, "");
+    static_assert(std::is_signed<std::streamsize>::value, "");
+}
diff --git a/test/input.output/iostreams.base/version.pass.cpp b/test/input.output/iostreams.base/version.pass.cpp
new file mode 100644
index 0000000..62bcfa8
--- /dev/null
+++ b/test/input.output/iostreams.base/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp b/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp b/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp b/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp b/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/nothing_to_do.pass.cpp b/test/input.output/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp b/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp b/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
new file mode 100644
index 0000000..b7736cb
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs);  // protected
+
+#include <streambuf>
+#include <cassert>
+
+std::streambuf get();
+
+int main()
+{
+    std::streambuf sb = get();
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
new file mode 100644
index 0000000..3f9f7d5
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    test(const test& t)
+        : std::basic_streambuf<CharT>(t)
+    {
+        assert(this->eback() == t.eback());
+        assert(this->gptr()  == t.gptr());
+        assert(this->egptr() == t.egptr());
+        assert(this->pbase() == t.pbase());
+        assert(this->pptr()  == t.pptr());
+        assert(this->epptr() == t.epptr());
+        assert(this->getloc() == t.getloc());
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2 = t;
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2 = t;
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2 = t;
+    }
+    std::locale::global(std::locale("en_US"));
+    {
+        test<char> t;
+        test<char> t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2 = t;
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp b/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
new file mode 100644
index 0000000..3ae29ff
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf();  // is protected
+
+#include <streambuf>
+
+int main()
+{
+    std::basic_streambuf<char> sb;
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
new file mode 100644
index 0000000..975b1a3
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf();
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test()
+    {
+        assert(this->eback() == 0);
+        assert(this->gptr() == 0);
+        assert(this->egptr() == 0);
+        assert(this->pbase() == 0);
+        assert(this->pptr() == 0);
+        assert(this->epptr() == 0);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.getloc().name() == "C");
+    }
+    {
+        test<wchar_t> t;
+        assert(t.getloc().name() == "C");
+    }
+    std::locale::global(std::locale("en_US"));
+    {
+        test<char> t;
+        assert(t.getloc().name() == "en_US");
+    }
+    {
+        test<wchar_t> t;
+        assert(t.getloc().name() == "en_US");
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
new file mode 100644
index 0000000..4fc6ff0
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekoff(off_type off, ios_base::seekdir way, 
+//                     ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubseekoff(0, std::ios_base::beg) == -1);
+        assert(t.pubseekoff(0, std::ios_base::beg, std::ios_base::app) == -1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
new file mode 100644
index 0000000..a50594e
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekpos(pos_type sp, 
+//                     ios_base::openmode which = ios_base::in | ios_base::out;
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubseekpos(0, std::ios_base::app) == -1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
new file mode 100644
index 0000000..f558f5f
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf* pubsetbuf(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubsetbuf(0, 0) == &t);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
new file mode 100644
index 0000000..166a57a
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int pubsync();
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubsync() == 0);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp
new file mode 100644
index 0000000..68ff5e5
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// locale pubimbue(const locale& loc);
+// locale getloc() const;
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+
+    void imbue(const std::locale&)
+    {
+        assert(this->getloc().name() == "en_US");
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.getloc().name() == "C");
+    }
+    std::locale::global(std::locale("en_US"));
+    {
+        test<char> t;
+        assert(t.getloc().name() == "en_US");
+        assert(t.pubimbue(std::locale("fr_FR")).name() == "en_US");
+        assert(t.getloc().name() == "fr_FR");
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
new file mode 100644
index 0000000..d476030
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize in_avail();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+protected:
+    std::streamsize showmanyc()
+    {
+        ++showmanyc_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.in_avail() == 5);
+        assert(showmanyc_called == 1);
+        char in[5];
+        t.setg(in, in+2, in+5);
+        assert(t.in_avail() == 3);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp
new file mode 100644
index 0000000..179d72f
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sbumpc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type uflow()
+    {
+        ++uflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(uflow_called == 0);
+        assert(t.sbumpc() == 'a');
+        assert(uflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.sbumpc() == 'A');
+        assert(uflow_called == 1);
+        assert(t.sbumpc() == 'B');
+        assert(uflow_called == 1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp
new file mode 100644
index 0000000..44fd1bc
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sgetc();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type underflow()
+    {
+        ++underflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(underflow_called == 0);
+        assert(t.sgetc() == 'a');
+        assert(underflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.sgetc() == 'A');
+        assert(underflow_called == 1);
+        assert(t.sgetc() == 'A');
+        assert(underflow_called == 1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
new file mode 100644
index 0000000..47daa3a
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsgetn_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+protected:
+    std::streamsize xsgetn(char_type* s, std::streamsize n)
+    {
+        ++xsgetn_called;
+        return 10;
+    }
+};
+
+int main()
+{
+    test t;
+    assert(xsgetn_called == 0);
+    assert(t.sgetn(0, 0) == 10);
+    assert(xsgetn_called == 1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp
new file mode 100644
index 0000000..e4121b5
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type snextc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type uflow()
+    {
+        ++uflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(uflow_called == 0);
+        assert(t.snextc() == -1);
+        assert(uflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.snextc() == 'B');
+        assert(uflow_called == 1);
+        assert(t.snextc() == 'C');
+        assert(uflow_called == 1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp
new file mode 100644
index 0000000..0b113fd
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputbackc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type pbackfail(int_type c = traits_type::eof())
+    {
+        ++pbackfail_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(pbackfail_called == 0);
+        assert(t.sputbackc('A') == 'a');
+        assert(pbackfail_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in));
+        assert(t.sputbackc('A') == 'A');
+        assert(pbackfail_called == 1);
+        assert(t.sputbackc('A') == 'a');
+        assert(pbackfail_called == 2);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp
new file mode 100644
index 0000000..9d69a9e
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sungetc();
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type pbackfail(int_type c = traits_type::eof())
+    {
+        ++pbackfail_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(pbackfail_called == 0);
+        assert(t.sungetc() == 'a');
+        assert(pbackfail_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in));
+        assert(t.sungetc() == 'A');
+        assert(pbackfail_called == 1);
+        assert(t.sungetc() == 'a');
+        assert(pbackfail_called == 2);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
new file mode 100644
index 0000000..c46042c
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int overflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(char* pbeg, char* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+
+protected:
+    int_type overflow(int_type c = traits_type::eof())
+    {
+        ++overflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(overflow_called == 0);
+        assert(t.sputc('A') == 'a');
+        assert(overflow_called == 1);
+        char out[3] = {0};
+        t.setp(out, out+sizeof(out));
+        assert(t.sputc('A') == 'A');
+        assert(overflow_called == 1);
+        assert(out[0] == 'A');
+        assert(t.sputc('B') == 'B');
+        assert(overflow_called == 1);
+        assert(out[0] == 'A');
+        assert(out[1] == 'B');
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
new file mode 100644
index 0000000..4209671
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsputn_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+protected:
+    std::streamsize xsputn(const char_type* s, std::streamsize n)
+    {
+        ++xsputn_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    test t;
+    assert(xsputn_called == 0);
+    assert(t.sputn(0, 0) == 5);
+    assert(xsputn_called == 1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
new file mode 100644
index 0000000..87c04e4
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf& operator=(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    test& operator=(const test& t)
+    {
+        base::operator=(t);
+        assert(this->eback() == t.eback());
+        assert(this->gptr()  == t.gptr());
+        assert(this->egptr() == t.egptr());
+        assert(this->pbase() == t.pbase());
+        assert(this->pptr()  == t.pptr());
+        assert(this->epptr() == t.epptr());
+        assert(this->getloc() == t.getloc());
+        return *this;
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        t2 = t;
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2;
+        t2 = t;
+    }
+    std::locale::global(std::locale("en_US"));
+    {
+        test<char> t;
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        t2 = t;
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
new file mode 100644
index 0000000..5cfd9f0
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void swap(basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    void swap(test& t)
+    {
+        test old_this(*this);
+        test old_that(t);
+        base::swap(t);
+        assert(this->eback() == old_that.eback());
+        assert(this->gptr()  == old_that.gptr());
+        assert(this->egptr() == old_that.egptr());
+        assert(this->pbase() == old_that.pbase());
+        assert(this->pptr()  == old_that.pptr());
+        assert(this->epptr() == old_that.epptr());
+        assert(this->getloc() == old_that.getloc());
+
+        assert(t.eback() == old_this.eback());
+        assert(t.gptr()  == old_this.gptr());
+        assert(t.egptr() == old_this.egptr());
+        assert(t.pbase() == old_this.pbase());
+        assert(t.pptr()  == old_this.pptr());
+        assert(t.epptr() == old_this.epptr());
+        assert(t.getloc() == old_this.getloc());
+        return *this;
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+    std::locale::global(std::locale("en_US"));
+    {
+        test<char> t;
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
new file mode 100644
index 0000000..021a137
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void gbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+    void gbump(int n)
+    {
+        CharT* gbeg = base::eback();
+        CharT* gnext = base::gptr();
+        CharT* gend = base::egptr();
+        base::gbump(n);
+        assert(base::eback() == gbeg);
+        assert(base::gptr() == gnext+n);
+        assert(base::egptr() == gend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABCDE";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+        t.gbump(2);
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABCDE";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+        t.gbump(3);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
new file mode 100644
index 0000000..8ca539c
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setg(char_type* gbeg, char_type* gnext, char_type* gend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+        assert(base::eback() == gbeg);
+        assert(base::gptr() == gnext);
+        assert(base::egptr() == gend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABC";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
new file mode 100644
index 0000000..7a062d0
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void pbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+
+    void pbump(int n)
+    {
+        CharT* pbeg = base::pbase();
+        CharT* pnext = base::pptr();
+        CharT* pend = base::epptr();
+        base::pbump(n);
+        assert(base::pbase() == pbeg);
+        assert(base::pptr() == pnext+n);
+        assert(base::epptr() == pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABCDE";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+        t.pbump(2);
+        t.pbump(1);
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABCDE";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+        t.pbump(3);
+        t.pbump(1);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
new file mode 100644
index 0000000..b727c5a
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setp(char_type* pbeg, char_type* pend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+        assert(base::pbase() == pbeg);
+        assert(base::pptr() == pbeg);
+        assert(base::epptr() == pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABC";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABC";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
new file mode 100644
index 0000000..c9b328e
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize showmanyc();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    test<char> t;
+    assert(t.in_avail() == 0);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
new file mode 100644
index 0000000..74d08f8
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type uflow();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+};
+
+int main()
+{
+    test t;
+    assert(t.sgetc() == -1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
new file mode 100644
index 0000000..b39fbf3
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type underflow();
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sgetc() == -1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
new file mode 100644
index 0000000..799443b
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+};
+
+int main()
+{
+    test t;
+    char input[7] = "123456";
+    t.setg(input, input, input+7);
+    char output[sizeof(input)] = {0};
+    assert(t.sgetn(output, 10) == 7);
+    assert(strcmp(input, output) == 0);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp
new file mode 100644
index 0000000..4609ff9
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sputbackc('A') == -1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
new file mode 100644
index 0000000..96183ef
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sputc('A') == -1);
+}
diff --git a/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
new file mode 100644
index 0000000..95d522e
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setp(char* pbeg, char* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        char in[] = "123456";
+        assert(t.sputn(in, sizeof(in)) == 0);
+        char out[sizeof(in)] = {0};
+        t.setp(out, out+sizeof(out));
+        assert(t.sputn(in, sizeof(in)) == sizeof(in));
+        assert(strcmp(in, out) == 0);
+    }
+}
diff --git a/test/input.output/stream.buffers/streambuf/types.pass.cpp b/test/input.output/stream.buffers/streambuf/types.pass.cpp
new file mode 100644
index 0000000..664caeb
--- /dev/null
+++ b/test/input.output/stream.buffers/streambuf/types.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf
+// {
+// public:
+//     // types:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <streambuf>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::streambuf::char_type, char>::value), "");
+    static_assert((std::is_same<std::streambuf::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::streambuf::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::streambuf::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::streambuf::off_type, std::char_traits<char>::off_type>::value), "");
+
+    static_assert((std::is_same<std::wstreambuf::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::wstreambuf::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<std::wstreambuf::int_type, std::char_traits<wchar_t>::int_type>::value), "");
+    static_assert((std::is_same<std::wstreambuf::pos_type, std::char_traits<wchar_t>::pos_type>::value), "");
+    static_assert((std::is_same<std::wstreambuf::off_type, std::char_traits<wchar_t>::off_type>::value), "");
+}
diff --git a/test/input.output/stream.buffers/version.pass.cpp b/test/input.output/stream.buffers/version.pass.cpp
new file mode 100644
index 0000000..8d9de9f
--- /dev/null
+++ b/test/input.output/stream.buffers/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+#include <streambuf>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..75237e7
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void swap(basic_istringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..8ac3fda
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream& operator=(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..696dd5b
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// template <class charT, class traits, class Allocator> 
+//   void
+//   swap(basic_istringstream<charT, traits, Allocator>& x,
+//        basic_istringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..83933f7
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::istringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wistringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wistringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..83d66bb
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..5ff47e6
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.cons/string.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str, 
+//                              ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::istringstream ss(" 123 456", std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss(L" 123 456", std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+}
diff --git a/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp b/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
new file mode 100644
index 0000000..08b01d3
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/istringstream.members/str.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss.str(" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == " 789");
+        ss >> i;
+        assert(i == 789);
+    }
+    {
+        std::wistringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss.str(L" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == L" 789");
+        ss >> i;
+        assert(i == 789);
+    }
+}
diff --git a/test/input.output/string.streams/istringstream/types.pass.cpp b/test/input.output/string.streams/istringstream/types.pass.cpp
new file mode 100644
index 0000000..8d88da9
--- /dev/null
+++ b/test/input.output/string.streams/istringstream/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+//     : public basic_istream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_istringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..c2ab4f5
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == "234 567");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == L"234 567");
+    }
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..664473d
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.assign/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream& operator=(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..c978063
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == "234 567");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == L"234 567");
+    }
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..96140bc
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::ostringstream ss(std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wostringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wostringstream ss(std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..799ea36
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..6707ae8
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str, 
+//                              ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::ostringstream ss(" 123 456", std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+    {
+        std::wostringstream ss(L" 123 456", std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+}
diff --git a/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
new file mode 100644
index 0000000..0025da9
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss << i;
+        assert(ss.str() == "0123 456");
+        ss << 456;
+        assert(ss.str() == "0456 456");
+        ss.str(" 789");
+        assert(ss.str() == " 789");
+        ss << "abc";
+        assert(ss.str() == "abc9");
+    }
+    {
+        std::wostringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss << i;
+        assert(ss.str() == L"0123 456");
+        ss << 456;
+        assert(ss.str() == L"0456 456");
+        ss.str(L" 789");
+        assert(ss.str() == L" 789");
+        ss << L"abc";
+        assert(ss.str() == L"abc9");
+    }
+}
diff --git a/test/input.output/string.streams/ostringstream/types.pass.cpp b/test/input.output/string.streams/ostringstream/types.pass.cpp
new file mode 100644
index 0000000..24fe1ff
--- /dev/null
+++ b/test/input.output/string.streams/ostringstream/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+//     : public basic_ostream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..0562cea
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void swap(basic_stringbuf& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
new file mode 100644
index 0000000..84a978f
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf& operator=(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..451a838
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// template <class charT, class traits, class Allocator> 
+//   void swap(basic_stringbuf<charT, traits, Allocator>& x, 
+//             basic_stringbuf<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
new file mode 100644
index 0000000..f8231ba
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf;
+        assert(buf.str() == "");
+    }
+    {
+        std::wstringbuf buf;
+        assert(buf.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
new file mode 100644
index 0000000..bec0464
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
new file mode 100644
index 0000000..53c0081
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s, 
+//                          ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::in);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::out);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::in);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::out);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
new file mode 100644
index 0000000..601e5bc
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+        buf.str("another test");
+        assert(buf.str() == "another test");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+        buf.str(L"another test");
+        assert(buf.str() == L"another test");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..048f05d
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+int overflow_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        overflow(typename base::int_type c = base::type_traits::eof())
+        {++overflow_called; return base::overflow(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("abc");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "1bc");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "12c");
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "123");
+        assert(sb.sputc('4') == '4');
+        assert(sb.str() == "1234");
+        assert(sb.sputc('5') == '5');
+        assert(sb.str() == "12345");
+        assert(sb.sputc('6') == '6');
+        assert(sb.str() == "123456");
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "1234567");
+        assert(sb.sputc('8') == '8');
+        assert(sb.str() == "12345678");
+        assert(sb.sputc('9') == '9');
+        assert(sb.str() == "123456789");
+        assert(sb.sputc('0') == '0');
+        assert(sb.str() == "1234567890");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "12345678901");
+    }
+    {
+        testbuf<wchar_t> sb(L"abc");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"1bc");
+        assert(sb.sputc(L'2') == L'2');
+        assert(sb.str() == L"12c");
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"123");
+        assert(sb.sputc(L'4') == L'4');
+        assert(sb.str() == L"1234");
+        assert(sb.sputc(L'5') == L'5');
+        assert(sb.str() == L"12345");
+        assert(sb.sputc(L'6') == L'6');
+        assert(sb.str() == L"123456");
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"1234567");
+        assert(sb.sputc(L'8') == L'8');
+        assert(sb.str() == L"12345678");
+        assert(sb.sputc(L'9') == L'9');
+        assert(sb.str() == L"123456789");
+        assert(sb.sputc(L'0') == L'0');
+        assert(sb.str() == L"1234567890");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"12345678901");
+    }
+    {
+        testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out);
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "abc1");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "abc12");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..0f85c0c
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        pbackfail(typename base::int_type c = base::type_traits::eof())
+        {return base::pbackfail(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123", std::ios_base::in);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == std::char_traits<char>::eof());
+        assert(sb.pbackfail('2') == '2');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb("123");
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "133");
+    }
+    {
+        testbuf<wchar_t> sb(L"123", std::ios_base::in);
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'2') == L'2');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"133");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..43cc9e0
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way, 
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('b') == 'b');
+        assert(sb.str() == "012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "0123456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'b') == L'b');
+        assert(sb.str() == L"012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"0123456c89");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 0000000..6e2d832
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 0000000..184e759
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..1f5b91e
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type underflow();
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str)
+        : base(str) {}
+
+    typename base::int_type underflow() {return base::underflow();}
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123");
+        sb.pbump(3);
+        assert(sb.underflow() == '1');
+        assert(sb.underflow() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        sb.sputc('4');
+        assert(sb.underflow() == '4');
+        assert(sb.underflow() == '4');
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        sb.pbump(3);
+        assert(sb.underflow() == L'1');
+        assert(sb.underflow() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        sb.sputc(L'4');
+        assert(sb.underflow() == L'4');
+        assert(sb.underflow() == L'4');
+    }
+}
diff --git a/test/input.output/string.streams/stringbuf/types.pass.cpp b/test/input.output/string.streams/stringbuf/types.pass.cpp
new file mode 100644
index 0000000..84930d6
--- /dev/null
+++ b/test/input.output/string.streams/stringbuf/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+//     : public basic_streambuf<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_stringbuf<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/input.output/string.streams/stringstream.cons/default.pass.cpp b/test/input.output/string.streams/stringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..e8c7325
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::stringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wstringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wstringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/test/input.output/string.streams/stringstream.cons/move.pass.cpp b/test/input.output/string.streams/stringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..da68210
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/stringstream.cons/string.pass.cpp b/test/input.output/string.streams/stringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..e1e7f63
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/string.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str, 
+//                             ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss(" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss(L" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+}
diff --git a/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..6517d20
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void swap(basic_stringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == "456 123");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == L"456 123");
+    }
+}
diff --git a/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..cffc430
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream& operator=(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+#endif
+}
diff --git a/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..f5ee292
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// template <class charT, class traits, class Allocator> 
+//   void
+//   swap(basic_stringstream<charT, traits, Allocator>& x, 
+//        basic_stringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == "456 123");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == L"456 123");
+    }
+}
diff --git a/test/input.output/string.streams/stringstream.members/str.pass.cpp b/test/input.output/string.streams/stringstream.members/str.pass.cpp
new file mode 100644
index 0000000..1352d0f
--- /dev/null
+++ b/test/input.output/string.streams/stringstream.members/str.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void str(const basic_string<charT,traits,Allocator>& str);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss(" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss.str("5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == "89 3219 ");
+    }
+    {
+        std::wstringstream ss(L" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss.str(L"5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == L"89 3219 ");
+    }
+}
diff --git a/test/input.output/string.streams/stringstream/types.pass.cpp b/test/input.output/string.streams/stringstream/types.pass.cpp
new file mode 100644
index 0000000..0b64c24
--- /dev/null
+++ b/test/input.output/string.streams/stringstream/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+//     : public basic_iostream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_stringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/test/input.output/string.streams/version.pass.cpp b/test/input.output/string.streams/version.pass.cpp
new file mode 100644
index 0000000..0567394
--- /dev/null
+++ b/test/input.output/string.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+#include <sstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp b/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
new file mode 100644
index 0000000..848992b
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Category, class T, class Distance = ptrdiff_t, 
+//          class Pointer = T*, class Reference = T&> 
+// struct iterator
+// { 
+//   typedef T         value_type; 
+//   typedef Distance  difference_type; 
+//   typedef Pointer   pointer; 
+//   typedef Reference reference; 
+//   typedef Category  iterator_category; 
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+template <class T>
+void
+test2()
+{
+    typedef std::iterator<std::forward_iterator_tag, T> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<typename It::pointer, T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test3()
+{
+    typedef std::iterator<std::bidirectional_iterator_tag, T, short> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, short>::value), "");
+    static_assert((std::is_same<typename It::pointer, T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::bidirectional_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test4()
+{
+    typedef std::iterator<std::random_access_iterator_tag, T, int, const T*> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, int>::value), "");
+    static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test5()
+{
+    typedef std::iterator<std::input_iterator_tag, T, long, const T*, const T&> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, long>::value), "");
+    static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+    static_assert((std::is_same<typename It::reference, const T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::input_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test2<A>();
+    test3<A>();
+    test4<A>();
+    test5<A>();
+}
diff --git a/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp b/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
new file mode 100644
index 0000000..9b5e30c
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.operations/advance.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter> 
+//   void advance(Iter& i, Iter::difference_type n);
+// 
+// template <BidirectionalIterator Iter> 
+//   void advance(Iter& i, Iter::difference_type n); 
+// 
+// template <RandomAccessIterator Iter> 
+//   void advance(Iter& i, Iter::difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::advance(i, n);
+    assert(i == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10));
+    test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s+10);
+    test(s+5, -5, s);
+}
diff --git a/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp b/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
new file mode 100644
index 0000000..5b7b0cb
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter> 
+//   Iter::difference_type 
+//   distance(Iter first, Iter last); 
+// 
+// template <RandomAccessIterator Iter> 
+//   Iter::difference_type
+//   distance(Iter first, Iter last);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class It>
+void
+test(It first, It last, typename std::iterator_traits<It>::difference_type x)
+{
+    assert(std::distance(first, last) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10);
+    test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10);
+    test(s, s+10, 10);
+}
diff --git a/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp b/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp
new file mode 100644
index 0000000..4e36eab
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.operations/next.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter> 
+//   Iter next(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    assert(std::next(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+    assert(std::next(i) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10));
+    test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10));
+    test(s, 10, s+10);
+
+    test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1));
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1));
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
+    test(s, s+1);
+}
diff --git a/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp b/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
new file mode 100644
index 0000000..9938a99
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.operations/prev.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BidirectionalIterator Iter> 
+//   Iter prev(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    assert(std::prev(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+    assert(std::prev(i) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s));
+    test(s+10, 10, s);
+
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp b/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
new file mode 100644
index 0000000..037db99
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<const T*>
+// {
+//   typedef ptrdiff_t                  difference_type;
+//   typedef T                          value_type;
+//   typedef const T*                   pointer;
+//   typedef const T&                   reference;
+//   typedef random_access_iterator_tag iterator_category;
+// };
+  
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    typedef std::iterator_traits<const A*> It;
+    static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, const A*>::value), "");
+    static_assert((std::is_same<It::reference, const A&>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp b/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
new file mode 100644
index 0000000..d3bbe5a
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.traits/empty.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class NotAnIterator>
+// struct iterator_traits
+// { 
+// };
+
+#include <iterator>
+
+struct not_an_iterator
+{
+};
+
+int main()
+{
+    typedef std::iterator_traits<not_an_iterator> It;
+}
diff --git a/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp b/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
new file mode 100644
index 0000000..841b17e
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Iter>
+// struct iterator_traits
+// { 
+//   typedef typename Iter::difference_type difference_type; 
+//   typedef typename Iter::value_type value_type; 
+//   typedef typename Iter::pointer pointer; 
+//   typedef typename Iter::reference reference; 
+//   typedef typename Iter::iterator_category iterator_category; 
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+struct test_iterator
+{
+    typedef int                       difference_type;
+    typedef A                         value_type;
+    typedef A*                        pointer;
+    typedef A&                        reference;
+    typedef std::forward_iterator_tag iterator_category;
+};
+
+int main()
+{
+    typedef std::iterator_traits<test_iterator> It;
+    static_assert((std::is_same<It::difference_type, int>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, A*>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp b/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
new file mode 100644
index 0000000..9680f46
--- /dev/null
+++ b/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<T*>
+// {
+//   typedef ptrdiff_t                  difference_type;
+//   typedef T                          value_type;
+//   typedef T*                         pointer;
+//   typedef T&                         reference;
+//   typedef random_access_iterator_tag iterator_category;
+// };
+  
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    typedef std::iterator_traits<A*> It;
+    static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, A*>::value), "");
+    static_assert((std::is_same<It::reference, A&>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/nothing_to_do.pass.cpp b/test/iterators/iterator.primitives/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.primitives/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp b/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
new file mode 100644
index 0000000..3d343e3
--- /dev/null
+++ b/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct bidirectional_iterator_tag : public forward_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::bidirectional_iterator_tag tag;
+    static_assert((std::is_base_of<std::forward_iterator_tag,
+                                   std::bidirectional_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::bidirectional_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp b/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
new file mode 100644
index 0000000..bb1b5b7
--- /dev/null
+++ b/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct forward_iterator_tag: public input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::forward_iterator_tag tag;
+    static_assert((std::is_base_of<std::input_iterator_tag,
+                                   std::forward_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::forward_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp b/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
new file mode 100644
index 0000000..ddbe1b2
--- /dev/null
+++ b/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::input_iterator_tag tag;
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::input_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp b/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
new file mode 100644
index 0000000..5d75f5b
--- /dev/null
+++ b/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct output_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::output_iterator_tag tag;
+    static_assert((!std::is_base_of<std::input_iterator_tag,
+                                    std::output_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp b/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
new file mode 100644
index 0000000..a6ec848
--- /dev/null
+++ b/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::random_access_iterator_tag tag;
+    static_assert((std::is_base_of<std::bidirectional_iterator_tag,
+                                   std::random_access_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp b/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp b/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterators.general/nothing_to_do.pass.cpp b/test/iterators/iterators.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/iterators.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/iterators.h b/test/iterators/iterators.h
new file mode 100644
index 0000000..85332ac
--- /dev/null
+++ b/test/iterators/iterators.h
@@ -0,0 +1,251 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+#endif
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000..2e7a56c
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <vector>
+
+int main()
+{
+    std::back_insert_iterator<std::vector<int> > i = std::vector<int>();
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000..f213484
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <vector>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..ff95280
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..3e80c6c
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..eea220c
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   back_insert_iterator<Cont>& 
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    const typename C::value_type v = typename C::value_type();
+    std::back_insert_iterator<C> i(c);
+    i = v;
+    assert(c.back() == v);
+}
+
+class Copyable
+{
+    int data_;
+public:
+    Copyable() : data_(0) {}
+    ~Copyable() {data_ = -1;}
+
+    friend bool operator==(const Copyable& x, const Copyable& y)
+        {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    test(std::vector<Copyable>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..8b00354
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   back_insert_iterator<Cont>& 
+//   operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifdef _LIBCPP_MOVE
+
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    i = typename C::value_type();
+    assert(c.back() == typename C::value_type());
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test(std::vector<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..437d500
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
new file mode 100644
index 0000000..ec568aa
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont> 
+//   back_insert_iterator<Cont>
+//   back_inserter(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i = std::back_inserter(c);
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp b/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..4efd53e
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// Test nested types and data member:
+
+// template <BackInsertionContainer Cont> 
+// class back_insert_iterator { 
+// protected: 
+//   Cont* container; 
+// public: 
+//   typedef Cont                        container_type; 
+//   typedef void                        value_type; 
+//   typedef void                        difference_type; 
+//   typedef back_insert_iterator<Cont>& reference; 
+//   typedef void                        pointer; 
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+    : private std::back_insert_iterator<C>
+{
+    explicit find_container(C& c) : std::back_insert_iterator<C>(c) {}
+    void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::back_insert_iterator<C> R;
+    C c;
+    find_container<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000..a9cf087
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <list>
+
+int main()
+{
+    std::front_insert_iterator<std::list<int> > i = std::list<int>();
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000..5b36b20
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <list>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+}
+
+int main()
+{
+    test(std::list<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..922789c
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::list<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..bf582a8
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::list<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..968a171
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& 
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    const typename C::value_type v = typename C::value_type();
+    std::front_insert_iterator<C> i(c);
+    i = v;
+    assert(c.front() == v);
+}
+
+class Copyable
+{
+    int data_;
+public:
+    Copyable() : data_(0) {}
+    ~Copyable() {data_ = -1;}
+
+    friend bool operator==(const Copyable& x, const Copyable& y)
+        {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    test(std::list<Copyable>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..48e54b5
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& 
+//   operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifdef _LIBCPP_MOVE
+
+#include <list>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    i = typename C::value_type();
+    assert(c.front() == typename C::value_type());
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    test(std::list<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..8d886c5
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::list<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
new file mode 100644
index 0000000..a218d02
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont> 
+//   front_insert_iterator<Cont>
+//   front_inserter(Cont& x);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i = std::front_inserter(c);
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.front() == 0);
+}
+
+int main()
+{
+    test(std::list<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp b/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..ebbc4ab
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// Test nested types and data member:
+
+// template <class Container> 
+// class front_insert_iterator { 
+// protected: 
+//   Container* container; 
+// public: 
+//   typedef Container                   container_type; 
+//   typedef void                        value_type; 
+//   typedef void                        difference_type; 
+//   typedef front_insert_iterator<Cont>& reference; 
+//   typedef void                        pointer;
+//   typedef output_iterator_tag         iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+    : private std::front_insert_iterator<C>
+{
+    explicit find_container(C& c) : std::front_insert_iterator<C>(c) {}
+    void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::front_insert_iterator<C> R;
+    C c;
+    find_container<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
new file mode 100644
index 0000000..7c803df
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.begin());
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..0b00c91
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..2838af5
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..87ca88a
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type> 
+//   insert_iterator<Cont>& 
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3, const C& c2)
+{
+    std::insert_iterator<C> q(c1, c1.begin() + j);
+    q = x1;
+    q = x2;
+    q = x3;
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3)
+{
+    i = c.insert(i, x1);
+    i = c.insert(++i, x2);
+    c.insert(++i, x3);
+}
+
+int main()
+{
+    typedef std::vector<int> C;
+    C c1;
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(i);
+    C c2 = c1;
+    insert3at(c2, c2.begin(), 'a', 'b', 'c');
+    test(c1, 0, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+    test(c1, 1, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+    test(c1, 2, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+    test(c1, 3, 'a', 'b', 'c', c2);
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..d4f6330
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type> 
+//   insert_iterator<Cont>& 
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+
+#ifdef _LIBCPP_MOVE
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3, const C& c2)
+{
+    std::insert_iterator<C> q(c1, c1.begin() + j);
+    q = std::move(x1);
+    q = std::move(x2);
+    q = std::move(x3);
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3)
+{
+    i = c.insert(i, std::move(x1));
+    i = c.insert(++i, std::move(x2));
+    c.insert(++i, std::move(x3));
+}
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::unique_ptr<int, do_nothing> Ptr;
+    typedef std::vector<Ptr> C;
+    C c1;
+    int x[6] = {0};
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    C c2;
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+#endif
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..e6dd492
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
new file mode 100644
index 0000000..96bd374
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InsertionContainer Cont> 
+//   insert_iterator<Cont>
+//   inserter(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i = std::inserter(c, c.end());
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp b/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..1c2dec0
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// Test nested types and data members:
+
+// template <InsertionContainer Cont> 
+// class insert_iterator { 
+// protected: 
+//   Cont* container; 
+//   Cont::iterator iter; 
+// public: 
+//   typedef Cont                   container_type; 
+//   typedef void                   value_type; 
+//   typedef void                   difference_type; 
+//   typedef insert_iterator<Cont>& reference; 
+//   typedef void                   pointer; 
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_members
+    : private std::insert_iterator<C>
+{
+    explicit find_members(C& c) : std::insert_iterator<C>(c, c.begin()) {}
+    void test()
+    {
+        this->container = 0;
+        this->iter == this->iter;
+    }
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::insert_iterator<C> R;
+    C c;
+    find_members<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
new file mode 100644
index 0000000..4c4c4fa
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter> 
+//   move_iterator<Iter>
+//   make_move_iterator(const Iter& i);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    const std::move_iterator<It> r(i);
+    assert(std::make_move_iterator(i) == r);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s+5));
+    test(forward_iterator<char*>(s+5));
+    test(bidirectional_iterator<char*>(s+5));
+    test(random_access_iterator<char*>(s+5));
+    test(s+5);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
new file mode 100644
index 0000000..7ab223e
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasMinus<Iter1, Iter2> 
+//   auto
+//   operator-(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y)
+//   -> decltype(x.base() - y.base());
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, typename std::iterator_traits<It>::difference_type x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert(r1 - r2 == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), random_access_iterator<char*>(s), 5);
+    test(s+5, s, 5);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
new file mode 100644
index 0000000..8203e02
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter> 
+//   move_iterator<Iter>
+//   operator+(Iter::difference_type n, const move_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = n + r;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
new file mode 100644
index 0000000..c1e6e8b
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   move_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r + n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
new file mode 100644
index 0000000..4a6f165
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   move_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = r += n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
new file mode 100644
index 0000000..9ba7f8a
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   move_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r - n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
new file mode 100644
index 0000000..8d6b473
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   move_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = r -= n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
new file mode 100644
index 0000000..4fd8560
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2> 
+//   bool
+//   operator==(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 == r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s), input_iterator<char*>(s), true);
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(s, s, true);
+    test(s, s+1, false);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
new file mode 100644
index 0000000..5875265
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter2, Iter1>
+//   bool
+//   operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 > r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+    test(s, s, false);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
new file mode 100644
index 0000000..87b6040
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter1, Iter2>
+//   bool
+//   operator>=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 >= r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+    test(s, s, true);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
new file mode 100644
index 0000000..12f3feb
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter1, Iter2>
+//   bool
+//   operator<(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 < r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+    test(s, s, false);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
new file mode 100644
index 0000000..8be4705
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter2, Iter1>
+//   bool
+//   operator<=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 <= r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+    test(s, s, true);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
new file mode 100644
index 0000000..1d4669a
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2> 
+//   bool
+//   operator!=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 != r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s), input_iterator<char*>(s), false);
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1), true);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s), false);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), true);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), false);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(s, s, false);
+    test(s, s+1, true);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
new file mode 100644
index 0000000..b1eeb0a
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U> 
+//   requires HasConstructor<Iter, const U&> 
+//   move_iterator(const move_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
new file mode 100644
index 0000000..c49697b
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U> 
+//   requires HasConstructor<Iter, const U&> 
+//   move_iterator(const move_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1 = r2;
+    assert(r1.base() == u);
+}
+
+struct base {};
+struct derived : base {};
+
+int main()
+{
+    derived d;
+
+    test<input_iterator<base*> >(input_iterator<derived*>(&d));
+    test<forward_iterator<base*> >(forward_iterator<derived*>(&d));
+    test<bidirectional_iterator<base*> >(bidirectional_iterator<derived*>(&d));
+    test<random_access_iterator<const base*> >(random_access_iterator<derived*>(&d));
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
new file mode 100644
index 0000000..dcebbe7
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator();
+
+#include <iterator>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test()
+{
+    std::move_iterator<It> r;
+}
+
+int main()
+{
+    test<input_iterator<char*> >();
+    test<forward_iterator<char*> >();
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
new file mode 100644
index 0000000..9759a74
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter );
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r = i;
+}
+
+int main()
+{
+    char s[] = "123";
+    test(s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
new file mode 100644
index 0000000..67a9d4c
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter i);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r(i);
+    assert(r.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s));
+    test(forward_iterator<char*>(s));
+    test(bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s));
+    test(s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
new file mode 100644
index 0000000..3f46f88
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r--;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+    test(s+1, s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
new file mode 100644
index 0000000..6f09436
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = --r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+    test(s+1, s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
new file mode 100644
index 0000000..6b7dcaa
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r++;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+    test(s, s+1);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
new file mode 100644
index 0000000..a65b579
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = ++r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+    test(s, s+1);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
new file mode 100644
index 0000000..9afbeb7
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+     typename std::iterator_traits<It>::value_type x)
+{
+    typedef typename std::iterator_traits<It>::value_type value_type;
+    const std::move_iterator<It> r(i);
+    value_type rr = r[n];
+    assert(rr == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), 4, '0');
+    test(s+5, 4, '0');
+#ifdef _LIBCPP_MOVE
+    int i[5];
+    typedef std::unique_ptr<int, do_nothing> Ptr;
+    Ptr p[5];
+    for (unsigned j = 0; j < 5; ++j)
+        p[j].reset(i+j);
+    test(p, 3, Ptr(i+3));
+#endif
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
new file mode 100644
index 0000000..382f7ba
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// pointer operator->() const;
+
+#include <iterator>
+#include <cassert>
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r(i);
+    assert(r.operator->() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(s);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000..7ffac7f
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// reference operator*() const;
+
+#include <iterator>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::move_iterator<It> r(i);
+    assert(*r == x);
+    typename std::iterator_traits<It>::value_type x2 = *r;
+    assert(x2 == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif
+
+int main()
+{
+    A a;
+    test(&a, A());
+#ifdef _LIBCPP_MOVE
+    int i;
+    std::unique_ptr<int, do_nothing> p(&i);
+    test(&p, std::unique_ptr<int, do_nothing>(&i));
+#endif
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
new file mode 100644
index 0000000..2c3a017
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U> 
+//   requires HasAssign<Iter, const U&> 
+//   move_iterator& 
+//   operator=(const move_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1;
+    r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
new file mode 100644
index 0000000..7a43429
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U> 
+//   requires HasAssign<Iter, const U&> 
+//   move_iterator& 
+//   operator=(const move_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1;
+    std::move_iterator<It>& rr = r1 = r2;
+    assert(r1.base() == u);
+    assert(&rr == &r1);
+}
+
+struct base {};
+struct derived : base {};
+
+int main()
+{
+    derived d;
+
+    test<input_iterator<base*> >(input_iterator<derived*>(&d));
+    test<forward_iterator<base*> >(forward_iterator<derived*>(&d));
+    test<bidirectional_iterator<base*> >(bidirectional_iterator<derived*>(&d));
+    test<random_access_iterator<const base*> >(random_access_iterator<derived*>(&d));
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
new file mode 100644
index 0000000..a9e4fe8
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/move.iterator/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// Test nested types:
+
+// template <InputIterator Iter> 
+// class move_iterator { 
+// public: 
+//   typedef Iter                  iterator_type; 
+//   typedef Iter::difference_type difference_type; 
+//   typedef Iterator              pointer; 
+//   typedef Iter::value_type      value_type; 
+//   typedef value_type&&          reference; 
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "../../../iterators.h"
+
+template <class It>
+void
+test()
+{
+    typedef std::move_iterator<It> R;
+    typedef std::iterator_traits<It> T;
+    static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+    static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+    static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
+    static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+#ifdef _LIBCPP_MOVE
+    static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
+#else
+    static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+#endif
+    static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+    test<input_iterator<char*> >();
+    test<forward_iterator<char*> >();
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
new file mode 100644
index 0000000..7dd8fb1
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator();
+
+#include <iterator>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test()
+{
+    std::reverse_iterator<It> r;
+}
+
+int main()
+{
+    test<bidirectional_iterator<const char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+    test<const char*>();
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
new file mode 100644
index 0000000..9ed84d2
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+    std::reverse_iterator<It> r = i;
+}
+
+int main()
+{
+    const char s[] = "123";
+    test(s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
new file mode 100644
index 0000000..e2633f0
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    std::reverse_iterator<It> r(i);
+    assert(r.base() == i);
+}
+
+int main()
+{
+    const char s[] = "123";
+    test(bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s));
+    test(s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
new file mode 100644
index 0000000..376932e
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U> 
+//   requires HasConstructor<Iter, const U&> 
+//   reverse_iterator(const reverse_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
new file mode 100644
index 0000000..923a594
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U> 
+//   requires HasConstructor<Iter, const U&> 
+//   reverse_iterator(const reverse_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1 = r2;
+    assert(r1.base() == u);
+}
+
+struct base {};
+struct derived : base {};
+
+int main()
+{
+    derived d;
+
+    test<bidirectional_iterator<base*> >(bidirectional_iterator<derived*>(&d));
+    test<random_access_iterator<const base*> >(random_access_iterator<derived*>(&d));
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git "a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp" "b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp"
new file mode 100644
index 0000000..1990f0e
--- /dev/null
+++ "b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp"
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2> 
+//   requires HasEqualTo<Iter1, Iter2> 
+//   bool
+//   operator!=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 != r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(s, s, false);
+    test(s, s+1, true);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..a29b82a
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r++;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..1bce569
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = ++r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
new file mode 100644
index 0000000..bfda849
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   reverse_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r + n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
new file mode 100644
index 0000000..dcd2d6e
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   reverse_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = r += n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
new file mode 100644
index 0000000..322a288
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r--;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+    test(s+1, s+2);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
new file mode 100644
index 0000000..ec26ab2
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = --r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+    test(s+1, s+2);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
new file mode 100644
index 0000000..a2a4e7a
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   reverse_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r - n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
new file mode 100644
index 0000000..641ce3f
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   reverse_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = r -= n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000..334b5da
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reference operator*() const;
+
+// Be sure to respect LWG 198:
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+
+#include <iterator>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+class weird_iterator
+{
+    It it_;
+public:
+    typedef It                              value_type;
+    typedef std::bidirectional_iterator_tag iterator_category;
+    typedef std::ptrdiff_t                  difference_type;
+    typedef It*                             pointer;
+    typedef It&                             reference;
+
+    weird_iterator() {}
+    explicit weird_iterator(It it) : it_(it) {}
+    ~weird_iterator() {it_ = It();}
+
+    reference operator*() {return it_;}
+
+    weird_iterator& operator--() {return *this;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::reverse_iterator<It> r(i);
+    assert(*r == x);
+}
+
+int main()
+{
+    test(weird_iterator<A>(A()), A());
+    A a;
+    test(&a+1, A());
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
new file mode 100644
index 0000000..7fc6948
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U> 
+//   requires HasAssign<Iter, const U&> 
+//   reverse_iterator& 
+//   operator=(const reverse_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1;
+    r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
new file mode 100644
index 0000000..a83a43a
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U> 
+//   requires HasAssign<Iter, const U&> 
+//   reverse_iterator& 
+//   operator=(const reverse_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1;
+    std::reverse_iterator<It>& rr = r1 = r2;
+    assert(r1.base() == u);
+    assert(&rr == &r1);
+}
+
+struct base {};
+struct derived : base {};
+
+int main()
+{
+    derived d;
+
+    test<bidirectional_iterator<base*> >(bidirectional_iterator<derived*>(&d));
+    test<random_access_iterator<const base*> >(random_access_iterator<derived*>(&d));
+    test<base*>(&d);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
new file mode 100644
index 0000000..0abc1d9
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2> 
+//   requires HasEqualTo<Iter1, Iter2> 
+//   bool
+//   operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 == r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(s, s, true);
+    test(s, s+1, false);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
new file mode 100644
index 0000000..3c08e33
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasMinus<Iter2, Iter1> 
+//   auto operator-(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y)
+//   -> decltype(y.base() - x.base());
+
+#include <iterator>
+#include <cstddef>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It1, class It2>
+void
+test(It1 l, It2 r, std::ptrdiff_t x)
+{
+    const std::reverse_iterator<It1> r1(l);
+    const std::reverse_iterator<It2> r2(r);
+    assert((r1 - r2) == x);
+}
+
+int main()
+{
+    char s[3] = {0};
+    test(random_access_iterator<const char*>(s), random_access_iterator<char*>(s), 0);
+    test(random_access_iterator<char*>(s), random_access_iterator<const char*>(s+1), 1);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<char*>(s), -1);
+    test(s, s, 0);
+    test(s, s+1, 1);
+    test(s+1, s, -1);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
new file mode 100644
index 0000000..c1367ec
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasGreater<Iter1, Iter2> 
+//   bool
+//   operator>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 > r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+    test(s, s, false);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
new file mode 100644
index 0000000..7dfcae8
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasGreater<Iter1, Iter2> 
+//   bool
+//   operator>=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 >= r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+    test(s, s, true);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
new file mode 100644
index 0000000..541d1e5
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter> 
+//   unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+     typename std::iterator_traits<It>::value_type x)
+{
+    typedef typename std::iterator_traits<It>::value_type value_type;
+    const std::reverse_iterator<It> r(i);
+    value_type rr = r[n];
+    assert(rr == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 4, '1');
+    test(s+5, 4, '1');
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
new file mode 100644
index 0000000..6594c25
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasGreater<Iter1, Iter2> 
+//   bool
+//   operator<(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 < r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+    test(s, s, false);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
new file mode 100644
index 0000000..123d2ed
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2> 
+//   requires HasGreater<Iter1, Iter2> 
+//   bool
+//   operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 <= r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+    test(s, s, true);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
new file mode 100644
index 0000000..0eddb2b
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// pointer operator->() const;
+
+// Be sure to respect LWG 198:
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+
+#include <iterator>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    int get() const {return data_;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+class weird_iterator
+{
+    It it_;
+public:
+    typedef It                              value_type;
+    typedef std::bidirectional_iterator_tag iterator_category;
+    typedef std::ptrdiff_t                  difference_type;
+    typedef It*                             pointer;
+    typedef It&                             reference;
+
+    weird_iterator() {}
+    explicit weird_iterator(It it) : it_(it) {}
+    ~weird_iterator() {it_ = It();}
+
+    reference operator*() {return it_;}
+    pointer operator->() {return &it_;}
+
+    weird_iterator& operator--() {return *this;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::reverse_iterator<It> r(i);
+    assert(r->get() == x.get());
+}
+
+int main()
+{
+    test(weird_iterator<A>(A()), A());
+    A a;
+    test(&a+1, A());
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
new file mode 100644
index 0000000..f1915d3
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iterator> 
+//   reverse_iterator<Iter>
+//   operator+(Iter::difference_type n, const reverse_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "../../../../iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = n + r;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp b/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
new file mode 100644
index 0000000..a2c5b85
--- /dev/null
+++ b/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// Test nested types and data member:
+
+// template <BidirectionalIterator Iter> 
+// class reverse_iterator { 
+// protected: 
+//   Iter current; 
+// public: 
+//   typedef Iter iterator_type; 
+//   typedef Iter::value_type value_type; 
+//   typedef Iter::difference_type difference_type; 
+//   typedef Iter::reference reference; 
+//   typedef Iter::pointer pointer; 
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "../../../iterators.h"
+
+template <class It>
+struct find_current
+    : private std::reverse_iterator<It>
+{
+    void test() {++(this->current);}
+};
+
+template <class It>
+void
+test()
+{
+    typedef std::reverse_iterator<It> R;
+    typedef std::iterator_traits<It> T;
+    find_current<It> q;
+    q.test();
+    static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+    static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+    static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+    static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+    static_assert((std::is_same<typename R::pointer, It>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
new file mode 100644
index 0000000..cf988f2
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(const istream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istream_iterator<int> io;
+        std::istream_iterator<int> i = io;
+        assert(i == std::istream_iterator<int>());
+    }
+    {
+        std::istringstream inf(" 1 23");
+        std::istream_iterator<int> io(inf);
+        std::istream_iterator<int> i = io;
+        assert(i != std::istream_iterator<int>());
+        int j = 0;
+        j = *i;
+        assert(j == 1);
+    }
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000..e0fa452
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    std::istream_iterator<int> i;
+    assert(i == std::istream_iterator<int>());
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000..d40edc5
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(istream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    assert(i != std::istream_iterator<int>());
+    assert(inf.peek() == ' ');
+    assert(inf.good());
+    int j = 0;
+    inf >> j;
+    assert(j == 23);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
new file mode 100644
index 0000000..6c79e54
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T* operator->() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+struct A
+{
+    double d_;
+    int i_;
+};
+
+std::istream& operator>>(std::istream& is, A& a)
+{
+    return is >> a.d_ >> a.i_;
+}
+
+int main()
+{
+    std::istringstream inf("1.5  23 ");
+    std::istream_iterator<A> i(inf);
+    assert(i->d_ == 1.5);
+    assert(i->i_ == 23);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000..5e068a1
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    int j = 0;
+    j = *i;
+    assert(j == 1);
+    j = *i;
+    assert(j == 1);
+    ++i;
+    j = *i;
+    assert(j == 23);
+    j = *i;
+    assert(j == 23);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
new file mode 100644
index 0000000..736c188
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// template <class T, class charT, class traits, class Distance>
+//   bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
+//                   const istream_iterator<T,charT,traits,Distance> &y);
+// 
+// template <class T, class charT, class traits, class Distance>
+//   bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
+//                   const istream_iterator<T,charT,traits,Distance> &y);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf1(" 1 23");
+    std::istringstream inf2(" 1 23");
+    std::istream_iterator<int> i1(inf1);
+    std::istream_iterator<int> i2(inf1);
+    std::istream_iterator<int> i3(inf2);
+    std::istream_iterator<int> i4;
+    std::istream_iterator<int> i5;
+    assert(i1 == i1);
+    assert(i1 == i2);
+    assert(i1 != i3);
+    assert(i1 != i4);
+    assert(i1 != i5);
+
+    assert(i2 == i2);
+    assert(i2 != i3);
+    assert(i2 != i4);
+    assert(i2 != i5);
+
+    assert(i3 == i3);
+    assert(i3 != i4);
+    assert(i3 != i5);
+
+    assert(i4 == i4);
+    assert(i4 == i5);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
new file mode 100644
index 0000000..7f24b81
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    std::istream_iterator<int> icopy = i++;
+    assert(icopy == i);
+    int j = 0;
+    j = *i;
+    assert(j == 23);
+    j = 0;
+    j = *icopy;
+    assert(j == 1);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
new file mode 100644
index 0000000..9031563
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator& operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    std::istream_iterator<int>& iref = ++i;
+    assert(&iref == &i);
+    int j = 0;
+    j = *i;
+    assert(j == 23);
+}
diff --git a/test/iterators/stream.iterators/istream.iterator/types.pass.cpp b/test/iterators/stream.iterators/istream.iterator/types.pass.cpp
new file mode 100644
index 0000000..dbfac03
--- /dev/null
+++ b/test/iterators/stream.iterators/istream.iterator/types.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+//           class Distance = ptrdiff_t>
+// class istream_iterator
+//     : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+// {
+// public:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef basic_istream<charT,traits> istream_type;
+//     ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    typedef std::istream_iterator<double> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
+        const double*, const double&> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+    typedef std::istream_iterator<unsigned, wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
+        const unsigned*, const unsigned&> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000..cf552a1
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator() throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istreambuf_iterator<char> i;
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istreambuf_iterator<wchar_t> i;
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000..9fd4862
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_istream<charT,traits>& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf;
+        std::istreambuf_iterator<char> i(inf);
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf("a");
+        std::istreambuf_iterator<char> i(inf);
+        assert(i != std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf;
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf(L"a");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(i != std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
new file mode 100644
index 0000000..79312ac
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(const proxy& p) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> j(inf);
+        std::istreambuf_iterator<char> i = j++;
+        assert(i != std::istreambuf_iterator<char>());
+        assert(*i == 'b');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> j(inf);
+        std::istreambuf_iterator<wchar_t> i = j++;
+        assert(i != std::istreambuf_iterator<wchar_t>());
+        assert(*i == L'b');
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..459a664
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istreambuf_iterator<char> i(nullptr);
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf;
+        std::istreambuf_iterator<char> i(inf.rdbuf());
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf("a");
+        std::istreambuf_iterator<char> i(inf.rdbuf());
+        assert(i != std::istreambuf_iterator<char>());
+    }
+    {
+        std::istreambuf_iterator<wchar_t> i(nullptr);
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf;
+        std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf(L"a");
+        std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+        assert(i != std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::equal/equal.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::equal/equal.pass.cpp
new file mode 100644
index 0000000..20bae45
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::equal/equal.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// bool equal(istreambuf_iterator<charT,traits>& b) const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert( i1.equal(i1));
+        assert( i1.equal(i2));
+        assert(!i1.equal(i3));
+        assert(!i1.equal(i4));
+
+        assert( i2.equal(i1));
+        assert( i2.equal(i2));
+        assert(!i2.equal(i3));
+        assert(!i2.equal(i4));
+
+        assert(!i3.equal(i1));
+        assert(!i3.equal(i2));
+        assert( i3.equal(i3));
+        assert( i3.equal(i4));
+
+        assert(!i4.equal(i1));
+        assert(!i4.equal(i2));
+        assert( i4.equal(i3));
+        assert( i4.equal(i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert( i1.equal(i1));
+        assert( i1.equal(i2));
+        assert(!i1.equal(i3));
+        assert(!i1.equal(i4));
+
+        assert( i2.equal(i1));
+        assert( i2.equal(i2));
+        assert(!i2.equal(i3));
+        assert(!i2.equal(i4));
+
+        assert(!i3.equal(i1));
+        assert(!i3.equal(i2));
+        assert( i3.equal(i3));
+        assert( i3.equal(i4));
+
+        assert(!i4.equal(i1));
+        assert(!i4.equal(i2));
+        assert( i4.equal(i3));
+        assert( i4.equal(i4));
+    }
+}
diff --git "a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op\041=/not_equal.pass.cpp" "b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op\041=/not_equal.pass.cpp"
new file mode 100644
index 0000000..1dd36b9
--- /dev/null
+++ "b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op\041=/not_equal.pass.cpp"
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+//   bool operator!=(const istreambuf_iterator<charT,traits>& a,
+//                   const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert(!(i1 != i1));
+        assert(!(i1 != i2));
+        assert( (i1 != i3));
+        assert( (i1 != i4));
+
+        assert(!(i2 != i1));
+        assert(!(i2 != i2));
+        assert( (i2 != i3));
+        assert( (i2 != i4));
+
+        assert( (i3 != i1));
+        assert( (i3 != i2));
+        assert(!(i3 != i3));
+        assert(!(i3 != i4));
+
+        assert( (i4 != i1));
+        assert( (i4 != i2));
+        assert(!(i4 != i3));
+        assert(!(i4 != i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert(!(i1 != i1));
+        assert(!(i1 != i2));
+        assert( (i1 != i3));
+        assert( (i1 != i4));
+
+        assert(!(i2 != i1));
+        assert(!(i2 != i2));
+        assert( (i2 != i3));
+        assert( (i2 != i4));
+
+        assert( (i3 != i1));
+        assert( (i3 != i2));
+        assert(!(i3 != i3));
+        assert(!(i3 != i4));
+
+        assert( (i4 != i1));
+        assert( (i4 != i2));
+        assert(!(i4 != i3));
+        assert(!(i4 != i4));
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op++/dereference.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op++/dereference.pass.cpp
new file mode 100644
index 0000000..3571f84
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op++/dereference.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// charT operator*() const
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i == 'a');
+        ++i;
+        assert(*i == 'b');
+        ++i;
+        assert(*i == 'c');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i == L'a');
+        ++i;
+        assert(*i == L'b');
+        ++i;
+        assert(*i == L'c');
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op==/equal.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op==/equal.pass.cpp
new file mode 100644
index 0000000..9c0bca4
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op==/equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+//   bool operator==(const istreambuf_iterator<charT,traits>& a,
+//                   const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert( (i1 == i1));
+        assert( (i1 == i2));
+        assert(!(i1 == i3));
+        assert(!(i1 == i4));
+
+        assert( (i2 == i1));
+        assert( (i2 == i2));
+        assert(!(i2 == i3));
+        assert(!(i2 == i4));
+
+        assert(!(i3 == i1));
+        assert(!(i3 == i2));
+        assert( (i3 == i3));
+        assert( (i3 == i4));
+
+        assert(!(i4 == i1));
+        assert(!(i4 == i2));
+        assert( (i4 == i3));
+        assert( (i4 == i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert( (i1 == i1));
+        assert( (i1 == i2));
+        assert(!(i1 == i3));
+        assert(!(i1 == i4));
+
+        assert( (i2 == i1));
+        assert( (i2 == i2));
+        assert(!(i2 == i3));
+        assert(!(i2 == i4));
+
+        assert(!(i3 == i1));
+        assert(!(i3 == i2));
+        assert( (i3 == i3));
+        assert( (i3 == i4));
+
+        assert(!(i4 == i1));
+        assert(!(i4 == i2));
+        assert( (i4 == i3));
+        assert( (i4 == i4));
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/arrow.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/arrow.pass.cpp
new file mode 100644
index 0000000..475608b
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/arrow.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// pointer operator->() const;
+
+#include <iostream> 
+#include <sstream>
+#include <streambuf> 
+
+typedef char C;
+int main ()
+{
+   std::istringstream s("filename");
+   std::istreambuf_iterator<char> i(s);
+
+   (*i).~C();  // This is well-formed...
+   i->~C();  // ... so this should be supported!
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/post_increment.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/post_increment.pass.cpp
new file mode 100644
index 0000000..8c31d5e
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/post_increment.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// proxy istreambuf_iterator<charT,traits>::operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i++ == 'a');
+        assert(*i++ == 'b');
+        assert(*i++ == 'c');
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i++ == L'a');
+        assert(*i++ == L'b');
+        assert(*i++ == L'c');
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/pre_increment.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/pre_increment.pass.cpp
new file mode 100644
index 0000000..4b315f0
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::op_astrk/pre_increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator<charT,traits>&
+//   istreambuf_iterator<charT,traits>::operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i == 'a');
+        assert(*++i == 'b');
+        assert(*++i == 'c');
+        assert(++i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i == L'a');
+        assert(*++i == L'b');
+        assert(*++i == L'c');
+        assert(++i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::proxy/proxy.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::proxy/proxy.pass.cpp
new file mode 100644
index 0000000..1f088df
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator::proxy/proxy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+//     : public iterator<input_iterator_tag, charT,
+//                       typename traits::off_type, charT*,
+//                       charT>
+// {
+// public:
+//     ...
+//     proxy operator++(int);
+
+// class proxy
+// {
+// public:
+//     charT operator*();
+// };
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i++ == 'a');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i++ == L'a');
+    }
+}
diff --git a/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp b/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000..7562332
--- /dev/null
+++ b/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+//     : public iterator<input_iterator_tag, charT,
+//                       typename traits::off_type, unspecified,
+//                       charT>
+// {
+// public:
+//     typedef charT                         char_type;
+//     typedef traits                        traits_type;
+//     typedef typename traits::int_type     int_type;
+//     typedef basic_streambuf<charT,traits> streambuf_type;
+//     typedef basic_istream<charT,traits>   istream_type;
+//     ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    typedef std::istreambuf_iterator<char> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
+        char*, char> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
+    static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+    static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+
+    typedef std::istreambuf_iterator<wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
+        wchar_t*, wchar_t> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
+    static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+    static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+}
diff --git a/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp b/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
new file mode 100644
index 0000000..9909ea8
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* begin(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    int* i = std::begin(ia);
+    assert(*i == 1);
+    *i = 2;
+    assert(ia[0] == 2);
+}
diff --git a/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp b/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
new file mode 100644
index 0000000..71fcce0
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::const_iterator i = begin(v);
+    assert(*i == 1);
+}
diff --git a/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp b/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
new file mode 100644
index 0000000..60aa74d
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::iterator i = begin(v);
+    assert(*i == 1);
+    *i = 2;
+    assert(*i == 2);
+}
diff --git a/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp b/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp
new file mode 100644
index 0000000..72ab1fb
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* end(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    int* i = std::begin(ia);
+    int* e = std::end(ia);
+    assert(e == ia + 3);
+    assert(e - i == 3);
+}
diff --git a/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp b/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp
new file mode 100644
index 0000000..f07bd3e
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(const C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::const_iterator i = end(v);
+    assert(i == v.cend());
+}
diff --git a/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp b/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
new file mode 100644
index 0000000..4571928
--- /dev/null
+++ b/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::iterator i = end(v);
+    assert(i == v.end());
+}
diff --git a/test/iterators/stream.iterators/nothing_to_do.pass.cpp b/test/iterators/stream.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/iterators/stream.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
new file mode 100644
index 0000000..7c61930
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(const ostream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream outf;
+    std::ostream_iterator<int> i(outf);
+    std::ostream_iterator<int> j = i;
+    assert(outf.good());
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
new file mode 100644
index 0000000..5a5b98d
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream outf;
+    std::ostream_iterator<int> i(outf);
+    assert(outf.good());
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
new file mode 100644
index 0000000..f83eddb
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s, const charT* delimiter);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf, ", ");
+        assert(outf.good());
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<double, wchar_t> i(outf, L", ");
+        assert(outf.good());
+    }
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
new file mode 100644
index 0000000..7252cf4
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator=(const T& value);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf);
+        i = 2.4;
+        assert(outf.str() == "2");
+    }
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf, ", ");
+        i = 2.4;
+        assert(outf.str() == "2, ");
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<int, wchar_t> i(outf);
+        i = 2.4;
+        assert(outf.str() == L"2");
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<int, wchar_t> i(outf, L", ");
+        i = 2.4;
+        assert(outf.str() == L"2, ");
+    }
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000..092deca
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream os;
+    std::ostream_iterator<int> i(os);
+    std::ostream_iterator<int>& iref = *i;
+    assert(&iref == &i);
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
new file mode 100644
index 0000000..665cac0
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator++();
+// ostream_iterator& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream os;
+    std::ostream_iterator<int> i(os);
+    std::ostream_iterator<int>& iref1 = ++i;
+    assert(&iref1 == &i);
+    std::ostream_iterator<int>& iref2 = i++;
+    assert(&iref2 == &i);
+}
diff --git a/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp b/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp
new file mode 100644
index 0000000..536c695
--- /dev/null
+++ b/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+//           class Distance = ptrdiff_t>
+// class ostream_iterator
+//     : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef basic_istream<charT,traits> istream_type;
+//     ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    typedef std::ostream_iterator<double> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+    typedef std::ostream_iterator<unsigned, wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
new file mode 100644
index 0000000..f564165
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(ostream_type& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        assert(!i.failed());
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        assert(!i.failed());
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..6634e3e
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(streambuf_type* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf.rdbuf());
+        assert(!i.failed());
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf.rdbuf());
+        assert(!i.failed());
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
new file mode 100644
index 0000000..35f8bb1
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>&
+//   operator=(charT c);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        i = 'a';
+        assert(outf.str() == "a");
+        i = 'b';
+        assert(outf.str() == "ab");
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        i = L'a';
+        assert(outf.str() == L"a");
+        i = L'b';
+        assert(outf.str() == L"ab");
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
new file mode 100644
index 0000000..8a1e5a1
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator*();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        std::ostreambuf_iterator<char>& iref = *i;
+        assert(&iref == &i);
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        std::ostreambuf_iterator<wchar_t>& iref = *i;
+        assert(&iref == &i);
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
new file mode 100644
index 0000000..ff69909
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// bool failed() const throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostreambuf_iterator<char> i(nullptr);
+        assert(i.failed());
+    }
+    {
+        std::ostreambuf_iterator<wchar_t> i(nullptr);
+        assert(i.failed());
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
new file mode 100644
index 0000000..79db935
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator++();
+// ostreambuf_iterator<charT,traits>& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        std::ostreambuf_iterator<char>& iref = ++i;
+        assert(&iref == &i);
+        std::ostreambuf_iterator<char>& iref2 = i++;
+        assert(&iref2 == &i);
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        std::ostreambuf_iterator<wchar_t>& iref = ++i;
+        assert(&iref == &i);
+        std::ostreambuf_iterator<wchar_t>& iref2 = i++;
+        assert(&iref2 == &i);
+    }
+}
diff --git a/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp b/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000..e2894b9
--- /dev/null
+++ b/test/iterators/stream.iterators/ostreambuf.iterator/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class charT, class traits = char_traits<charT> >
+// class ostreambuf_iterator
+//   : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+//   typedef charT                          char_type;
+//   typedef traits                         traits_type;
+//   typedef basic_streambuf<charT, traits> streambuf_type;
+//   typedef basic_ostream<charT, traits>   ostream_type;
+//   ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    typedef std::ostreambuf_iterator<char> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+    static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+
+    typedef std::ostreambuf_iterator<wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+    static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/iterators/version.pass.cpp b/test/iterators/version.pass.cpp
new file mode 100644
index 0000000..19cb755
--- /dev/null
+++ b/test/iterators/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp b/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
new file mode 100644
index 0000000..29bdd31
--- /dev/null
+++ b/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
@@ -0,0 +1,290 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdint>
+
+#include <cstdint>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    // typedef std::int8_t
+    static_assert(sizeof(std::int8_t)*CHAR_BIT == 8,
+                 "sizeof(std::int8_t)*CHAR_BIT == 8");
+    static_assert(std::is_signed<std::int8_t>::value,
+                 "std::is_signed<std::int8_t>::value");
+    // typedef std::int16_t
+    static_assert(sizeof(std::int16_t)*CHAR_BIT == 16,
+                 "sizeof(std::int16_t)*CHAR_BIT == 16");
+    static_assert(std::is_signed<std::int16_t>::value,
+                 "std::is_signed<std::int16_t>::value");
+    // typedef std::int32_t
+    static_assert(sizeof(std::int32_t)*CHAR_BIT == 32,
+                 "sizeof(std::int32_t)*CHAR_BIT == 32");
+    static_assert(std::is_signed<std::int32_t>::value,
+                 "std::is_signed<std::int32_t>::value");
+    // typedef std::int64_t
+    static_assert(sizeof(std::int64_t)*CHAR_BIT == 64,
+                 "sizeof(std::int64_t)*CHAR_BIT == 64");
+    static_assert(std::is_signed<std::int64_t>::value,
+                 "std::is_signed<std::int64_t>::value");
+
+    // typedef std::uint8_t
+    static_assert(sizeof(std::uint8_t)*CHAR_BIT == 8,
+                 "sizeof(std::uint8_t)*CHAR_BIT == 8");
+    static_assert(std::is_unsigned<std::uint8_t>::value,
+                 "std::is_unsigned<std::uint8_t>::value");
+    // typedef std::uint16_t
+    static_assert(sizeof(std::uint16_t)*CHAR_BIT == 16,
+                 "sizeof(std::uint16_t)*CHAR_BIT == 16");
+    static_assert(std::is_unsigned<std::uint16_t>::value,
+                 "std::is_unsigned<std::uint16_t>::value");
+    // typedef std::uint32_t
+    static_assert(sizeof(std::uint32_t)*CHAR_BIT == 32,
+                 "sizeof(std::uint32_t)*CHAR_BIT == 32");
+    static_assert(std::is_unsigned<std::uint32_t>::value,
+                 "std::is_unsigned<std::uint32_t>::value");
+    // typedef std::uint64_t
+    static_assert(sizeof(std::uint64_t)*CHAR_BIT == 64,
+                 "sizeof(std::uint64_t)*CHAR_BIT == 64");
+    static_assert(std::is_unsigned<std::uint64_t>::value,
+                 "std::is_unsigned<std::uint64_t>::value");
+
+    // typedef std::int_least8_t
+    static_assert(sizeof(std::int_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::int_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<std::int_least8_t>::value,
+                 "std::is_signed<std::int_least8_t>::value");
+    // typedef std::int_least16_t
+    static_assert(sizeof(std::int_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::int_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<std::int_least16_t>::value,
+                 "std::is_signed<std::int_least16_t>::value");
+    // typedef std::int_least32_t
+    static_assert(sizeof(std::int_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::int_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<std::int_least32_t>::value,
+                 "std::is_signed<std::int_least32_t>::value");
+    // typedef std::int_least64_t
+    static_assert(sizeof(std::int_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::int_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<std::int_least64_t>::value,
+                 "std::is_signed<std::int_least64_t>::value");
+
+    // typedef std::uint_least8_t
+    static_assert(sizeof(std::uint_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::uint_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<std::uint_least8_t>::value,
+                 "std::is_unsigned<std::uint_least8_t>::value");
+    // typedef std::uint_least16_t
+    static_assert(sizeof(std::uint_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::uint_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<std::uint_least16_t>::value,
+                 "std::is_unsigned<std::uint_least16_t>::value");
+    // typedef std::uint_least32_t
+    static_assert(sizeof(std::uint_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::uint_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<std::uint_least32_t>::value,
+                 "std::is_unsigned<std::uint_least32_t>::value");
+    // typedef std::uint_least64_t
+    static_assert(sizeof(std::uint_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::uint_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<std::uint_least64_t>::value,
+                 "std::is_unsigned<std::uint_least64_t>::value");
+
+    // typedef std::int_fast8_t
+    static_assert(sizeof(std::int_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::int_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<std::int_fast8_t>::value,
+                 "std::is_signed<std::int_fast8_t>::value");
+    // typedef std::int_fast16_t
+    static_assert(sizeof(std::int_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::int_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<std::int_fast16_t>::value,
+                 "std::is_signed<std::int_fast16_t>::value");
+    // typedef std::int_fast32_t
+    static_assert(sizeof(std::int_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::int_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<std::int_fast32_t>::value,
+                 "std::is_signed<std::int_fast32_t>::value");
+    // typedef std::int_fast64_t
+    static_assert(sizeof(std::int_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::int_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<std::int_fast64_t>::value,
+                 "std::is_signed<std::int_fast64_t>::value");
+
+    // typedef std::uint_fast8_t
+    static_assert(sizeof(std::uint_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::uint_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<std::uint_fast8_t>::value,
+                 "std::is_unsigned<std::uint_fast8_t>::value");
+    // typedef std::uint_fast16_t
+    static_assert(sizeof(std::uint_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::uint_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<std::uint_fast16_t>::value,
+                 "std::is_unsigned<std::uint_fast16_t>::value");
+    // typedef std::uint_fast32_t
+    static_assert(sizeof(std::uint_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::uint_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<std::uint_fast32_t>::value,
+                 "std::is_unsigned<std::uint_fast32_t>::value");
+    // typedef std::uint_fast64_t
+    static_assert(sizeof(std::uint_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::uint_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<std::uint_fast64_t>::value,
+                 "std::is_unsigned<std::uint_fast64_t>::value");
+
+    // typedef std::intptr_t
+    static_assert(sizeof(std::intptr_t) >= sizeof(void*),
+                 "sizeof(std::intptr_t) >= sizeof(void*)");
+    static_assert(std::is_signed<std::intptr_t>::value,
+                 "std::is_signed<std::intptr_t>::value");
+    // typedef std::uintptr_t
+    static_assert(sizeof(std::uintptr_t) >= sizeof(void*),
+                 "sizeof(std::uintptr_t) >= sizeof(void*)");
+    static_assert(std::is_unsigned<std::uintptr_t>::value,
+                 "std::is_unsigned<std::uintptr_t>::value");
+
+    // typedef std::intmax_t
+    static_assert(sizeof(std::intmax_t) >= sizeof(long long),
+                 "sizeof(std::intmax_t) >= sizeof(long long)");
+    static_assert(std::is_signed<std::intmax_t>::value,
+                 "std::is_signed<std::intmax_t>::value");
+    // typedef std::uintmax_t
+    static_assert(sizeof(std::uintmax_t) >= sizeof(unsigned long long),
+                 "sizeof(std::uintmax_t) >= sizeof(unsigned long long)");
+    static_assert(std::is_unsigned<std::uintmax_t>::value,
+                 "std::is_unsigned<std::uintmax_t>::value");
+
+    // INTN_MIN
+    static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+    static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+    static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+    static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+    // INTN_MAX
+    static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+    static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+    static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+    static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+    // UINTN_MAX
+    static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+    static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+    static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+    static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+    // INT_FASTN_MIN
+    static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+    static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+    static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+    static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+    // INT_FASTN_MAX
+    static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+    static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+    static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+    static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+    // UINT_FASTN_MAX
+    static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+    static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+    static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+    static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+    // INTPTR_MIN
+    assert(INTPTR_MIN == std::numeric_limits<std::intptr_t>::min());
+
+    // INTPTR_MAX
+    assert(INTPTR_MAX == std::numeric_limits<std::intptr_t>::max());
+
+    // UINTPTR_MAX
+    assert(UINTPTR_MAX == std::numeric_limits<std::uintptr_t>::max());
+
+    // INTMAX_MIN
+    assert(INTMAX_MIN == std::numeric_limits<std::intmax_t>::min());
+
+    // INTMAX_MAX
+    assert(INTMAX_MAX == std::numeric_limits<std::intmax_t>::max());
+
+    // UINTMAX_MAX
+    assert(UINTMAX_MAX == std::numeric_limits<std::uintmax_t>::max());
+
+    // PTRDIFF_MIN
+    assert(PTRDIFF_MIN == std::numeric_limits<std::ptrdiff_t>::min());
+
+    // PTRDIFF_MAX
+    assert(PTRDIFF_MAX == std::numeric_limits<std::ptrdiff_t>::max());
+
+    // SIG_ATOMIC_MIN
+    assert(SIG_ATOMIC_MIN == std::numeric_limits<std::sig_atomic_t>::min());
+
+    // SIG_ATOMIC_MAX
+    assert(SIG_ATOMIC_MAX == std::numeric_limits<std::sig_atomic_t>::max());
+
+    // SIZE_MAX
+    assert(SIZE_MAX == std::numeric_limits<std::size_t>::max());
+
+    // WCHAR_MIN
+    assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+    // WCHAR_MAX
+    assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+    // WINT_MIN
+    assert(WINT_MIN == std::numeric_limits<std::wint_t>::min());
+
+    // WINT_MAX
+    assert(WINT_MAX == std::numeric_limits<std::wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/test/language.support/cstdint/version.pass.cpp b/test/language.support/cstdint/version.pass.cpp
new file mode 100644
index 0000000..d842170
--- /dev/null
+++ b/test/language.support/cstdint/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdint>
+
+#include <cstdint>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/nothing_to_do.pass.cpp b/test/language.support/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp b/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
new file mode 100644
index 0000000..7ca8b80
--- /dev/null
+++ b/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_alloc
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_alloc>::value),
+                 "std::is_base_of<std::exception, std::bad_alloc>::value");
+    static_assert(std::is_polymorphic<std::bad_alloc>::value,
+                 "std::is_polymorphic<std::bad_alloc>::value");
+    std::bad_alloc b;
+    std::bad_alloc b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp b/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
new file mode 100644
index 0000000..bc4a6cd
--- /dev/null
+++ b/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_array_new_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value),
+                  "std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value");
+    static_assert(std::is_polymorphic<std::bad_array_new_length>::value,
+                 "std::is_polymorphic<std::bad_array_new_length>::value");
+    std::bad_array_new_length b;
+    std::bad_array_new_length b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
new file mode 100644
index 0000000..82ea243
--- /dev/null
+++ b/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test new_handler
+
+#include <new>
+
+void f() {}
+
+int main()
+{
+    std::new_handler p = f;
+}
diff --git a/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp b/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp b/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
new file mode 100644
index 0000000..6b7949d
--- /dev/null
+++ b/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test set_new_handler
+
+#include <new>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    assert(std::set_new_handler(f1) == 0);
+    assert(std::set_new_handler(f2) == f1);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
new file mode 100644
index 0000000..6396073
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new[]
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new[] (std::numeric_limits<std::size_t>::max());
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(new_handler_called == 1);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    delete [] ap;
+    assert(A_constructed == 0);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
new file mode 100644
index 0000000..182de18
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new [] (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow);
+        assert(new_handler_called == 1);
+        assert(vp == 0);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new(std::nothrow) A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    delete [] ap;
+    assert(A_constructed == 0);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
new file mode 100644
index 0000000..d06516c
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new [] nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    A* ap = new (std::nothrow) A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    assert(new_called);
+    delete [] ap;
+    assert(A_constructed == 0);
+    assert(!new_called);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
new file mode 100644
index 0000000..f673e05
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new[] replacement by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    A* ap = new A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    assert(new_called == 1);
+    delete [] ap;
+    assert(A_constructed == 0);
+    assert(new_called == 0);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
new file mode 100644
index 0000000..075bd39
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    char buf[sizeof(A)];
+
+    A* ap = new(buf) A;
+    assert((char*)ap == buf);
+    assert(A_constructed == 1);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
new file mode 100644
index 0000000..0179852
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new array
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    char buf[3*sizeof(A)];
+
+    A* ap = new(buf) A[3];
+    assert((char*)ap == buf);
+    assert(A_constructed == 3);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
new file mode 100644
index 0000000..54ac119
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new (std::numeric_limits<std::size_t>::max());
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(new_handler_called == 1);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new A;
+    assert(ap);
+    assert(A_constructed);
+    delete ap;
+    assert(!A_constructed);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
new file mode 100644
index 0000000..edbd802
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
+        assert(new_handler_called == 1);
+        assert(vp == 0);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new(std::nothrow) A;
+    assert(ap);
+    assert(A_constructed);
+    delete ap;
+    assert(!A_constructed);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
new file mode 100644
index 0000000..4ee05d5
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    A* ap = new (std::nothrow) A;
+    assert(ap);
+    assert(A_constructed);
+    assert(new_called);
+    delete ap;
+    assert(!A_constructed);
+    assert(!new_called);
+}
diff --git a/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
new file mode 100644
index 0000000..1d35f20
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test operator new replacement
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    A* ap = new A;
+    assert(ap);
+    assert(A_constructed);
+    assert(new_called);
+    delete ap;
+    assert(!A_constructed);
+    assert(!new_called);
+}
diff --git a/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp b/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.dynamic/version.pass.cpp b/test/language.support/support.dynamic/version.pass.cpp
new file mode 100644
index 0000000..3227380
--- /dev/null
+++ b/test/language.support/support.dynamic/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <new>
+
+#include <new>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp b/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp b/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
new file mode 100644
index 0000000..21de6f2
--- /dev/null
+++ b/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test set_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    std::set_terminate(f1);
+    assert(std::set_terminate(f2) == f1);
+}
diff --git a/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
new file mode 100644
index 0000000..0a3a457
--- /dev/null
+++ b/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test terminate_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+    std::terminate_handler p = f;
+}
diff --git a/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp b/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
new file mode 100644
index 0000000..b34051d
--- /dev/null
+++ b/test/language.support/support.exception/exception.terminate/terminate/terminate.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.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_terminate(f1);
+    std::terminate();
+    assert(false);
+}
diff --git a/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp b/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp
new file mode 100644
index 0000000..9f32dac
--- /dev/null
+++ b/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_exception>::value),
+                 "std::is_base_of<std::exception, std::bad_exception>::value");
+    static_assert(std::is_polymorphic<std::bad_exception>::value,
+                 "std::is_polymorphic<std::bad_exception>::value");
+    std::bad_exception b;
+    std::bad_exception b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp b/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
new file mode 100644
index 0000000..6f52ab7
--- /dev/null
+++ b/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test set_unexpected
+
+#include <exception>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    assert(std::set_unexpected(f1) == std::terminate);
+    assert(std::set_unexpected(f2) == f1);
+}
diff --git a/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
new file mode 100644
index 0000000..dbb5606
--- /dev/null
+++ b/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test unexpected_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+    std::unexpected_handler p = f;
+}
diff --git a/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp b/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp
new file mode 100644
index 0000000..0f441e2
--- /dev/null
+++ b/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.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.
+//
+//===----------------------------------------------------------------------===//
+ 
+// test unexpected
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_unexpected(f1);
+    std::unexpected();
+    assert(false);
+}
diff --git a/test/language.support/support.exception/exception/exception.pass.cpp b/test/language.support/support.exception/exception/exception.pass.cpp
new file mode 100644
index 0000000..d3ad7e4
--- /dev/null
+++ b/test/language.support/support.exception/exception/exception.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert(std::is_polymorphic<std::exception>::value,
+                 "std::is_polymorphic<std::exception>::value");
+    std::exception b;
+    std::exception b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.exception/propagation/current_exception.pass.cpp b/test/language.support/support.exception/propagation/current_exception.pass.cpp
new file mode 100644
index 0000000..95ba458
--- /dev/null
+++ b/test/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -0,0 +1,269 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// exception_ptr current_exception();
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+
+    A() {++constructed;}
+    ~A() {--constructed;}
+    A(const A&)  {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p = std::current_exception();
+        assert(p == nullptr);
+    }
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (A& a)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (A a)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 2);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 2);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                std::exception_ptr p = std::current_exception();
+                assert(A::constructed == 1);
+                assert(p != nullptr);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                std::exception_ptr p = std::current_exception();
+                assert(A::constructed == 1);
+                assert(p != nullptr);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        std::exception_ptr p = std::current_exception();
+        assert(A::constructed == 0);
+        assert(p == nullptr);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                p = std::current_exception();
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 1);
+        assert(p != nullptr);
+    }
+    assert(A::constructed == 0);
+}
diff --git a/test/language.support/support.exception/propagation/exception_ptr.pass.cpp b/test/language.support/support.exception/propagation/exception_ptr.pass.cpp
new file mode 100644
index 0000000..6c01768
--- /dev/null
+++ b/test/language.support/support.exception/propagation/exception_ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// typedef unspecified exception_ptr;
+
+// exception_ptr shall satisfy the requirements of NullablePointer.
+
+#include <exception>
+#include <cassert>
+
+int main()
+{
+    std::exception_ptr p;
+    assert(p == nullptr);
+    std::exception_ptr p2 = p;
+    assert(nullptr == p);
+    assert(!p);
+    assert(p2 == p);
+    p2 = p;
+    assert(p2 == p);
+    assert(p2 == nullptr);
+    std::exception_ptr p3 = nullptr;
+    assert(p3 == nullptr);
+    p3 = nullptr;
+    assert(p3 == nullptr);
+}
diff --git a/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
new file mode 100644
index 0000000..794199f
--- /dev/null
+++ b/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// template<class E> exception_ptr make_exception_ptr(E e);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+    int data_;
+
+    A(int data = 0) : data_(data) {++constructed;}
+    ~A() {--constructed;}
+    A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p = std::make_exception_ptr(A(5));
+        try
+        {
+            std::rethrow_exception(p);
+            assert(false);
+        }
+        catch (const A& a)
+        {
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p = nullptr;
+            assert(p == nullptr);
+            assert(a.data_ == 5);
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+}
diff --git a/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp
new file mode 100644
index 0000000..6cb19f7
--- /dev/null
+++ b/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// void rethrow_exception [[noreturn]] (exception_ptr p);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+    int data_;
+
+    A(int data = 0) : data_(data) {++constructed;}
+    ~A() {--constructed;}
+    A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p;
+        try
+        {
+            throw A(3);
+        }
+        catch (...)
+        {
+            p = std::current_exception();
+        }
+        try
+        {
+            std::rethrow_exception(p);
+            assert(false);
+        }
+        catch (const A& a)
+        {
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p = nullptr;
+            assert(p == nullptr);
+            assert(a.data_ == 3);
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+}
diff --git a/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
new file mode 100644
index 0000000..33ee877
--- /dev/null
+++ b/test/language.support/support.exception/uncaught/uncaught_exception.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test uncaught_exception
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    ~A()
+    {
+        assert(std::uncaught_exception());
+    }
+};
+
+int main()
+{
+    try
+    {
+        A a;
+        assert(!std::uncaught_exception());
+        throw 1;
+    }
+    catch (...)
+    {
+        assert(!std::uncaught_exception());
+    }
+    assert(!std::uncaught_exception());
+}
diff --git a/test/language.support/support.exception/version.pass.cpp b/test/language.support/support.exception/version.pass.cpp
new file mode 100644
index 0000000..db3013e
--- /dev/null
+++ b/test/language.support/support.exception/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+#include <exception>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.general/nothing_to_do.pass.cpp b/test/language.support/support.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.initlist/support.initlist.access/access.pass.cpp b/test/language.support/support.initlist/support.initlist.access/access.pass.cpp
new file mode 100644
index 0000000..169d125
--- /dev/null
+++ b/test/language.support/support.initlist/support.initlist.access/access.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// const E* begin() const;
+// const E* end() const;
+// size_t size() const;
+
+#include <initializer_list>
+#include <cassert>
+
+struct A
+{
+    A(std::initializer_list<int> il)
+    {
+        const int* b = il.begin();
+        const int* e = il.end();
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    A test1 = {3, 2, 1};
+#endif
+}
diff --git a/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp
new file mode 100644
index 0000000..f5147b9
--- /dev/null
+++ b/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// initializer_list();
+
+#include <initializer_list>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+    std::initializer_list<A> il;
+    assert(il.size() == 0);
+}
diff --git a/test/language.support/support.initlist/types.pass.cpp b/test/language.support/support.initlist/types.pass.cpp
new file mode 100644
index 0000000..c7af06e
--- /dev/null
+++ b/test/language.support/support.initlist/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E>
+// class initializer_list
+// {
+// public:
+//     typedef E        value_type;
+//     typedef const E& reference;
+//     typedef const E& const_reference;
+//     typedef size_t   size_type;
+// 
+//     typedef const E* iterator;
+//     typedef const E* const_iterator;
+
+#include <initializer_list>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    static_assert((std::is_same<std::initializer_list<A>::value_type, A>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::reference, const A&>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::const_reference, const A&>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::iterator, const A*>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::const_iterator, const A*>::value), "");
+}
diff --git a/test/language.support/support.initlist/version.pass.cpp b/test/language.support/support.initlist/version.pass.cpp
new file mode 100644
index 0000000..bf36347
--- /dev/null
+++ b/test/language.support/support.initlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+#include <initializer_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/c.limits/cfloat.pass.cpp b/test/language.support/support.limits/c.limits/cfloat.pass.cpp
new file mode 100644
index 0000000..8ec6337
--- /dev/null
+++ b/test/language.support/support.limits/c.limits/cfloat.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test cfloat
+
+#include <cfloat>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/c.limits/climits.pass.cpp b/test/language.support/support.limits/c.limits/climits.pass.cpp
new file mode 100644
index 0000000..265f260
--- /dev/null
+++ b/test/language.support/support.limits/c.limits/climits.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+ 
+ // test climits
+
+#include <climits>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp b/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp
new file mode 100644
index 0000000..c399be5
--- /dev/null
+++ b/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfloat>
+
+#include <cfloat>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/c.limits/version_climits.pass.cpp b/test/language.support/support.limits/c.limits/version_climits.pass.cpp
new file mode 100644
index 0000000..3ac5ea2
--- /dev/null
+++ b/test/language.support/support.limits/c.limits/version_climits.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <climits>
+
+#include <climits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp b/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
new file mode 100644
index 0000000..029dfe1
--- /dev/null
+++ b/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_round_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_round_style);
+two test(int);
+
+int main()
+{
+    static_assert(std::round_indeterminate == -1,
+                 "std::round_indeterminate == -1");
+    static_assert(std::round_toward_zero == 0,
+                 "std::round_toward_zero == 0");
+    static_assert(std::round_to_nearest == 1,
+                 "std::round_to_nearest == 1");
+    static_assert(std::round_toward_infinity == 2,
+                 "std::round_toward_infinity == 2");
+    static_assert(std::round_toward_neg_infinity == 3,
+                 "std::round_toward_neg_infinity == 3");
+    static_assert(sizeof(test(std::round_to_nearest)) == 1,
+                 "sizeof(test(std::round_to_nearest)) == 1");
+    static_assert(sizeof(test(1)) == 2,
+                 "sizeof(test(1)) == 2");
+}
diff --git a/test/language.support/support.limits/limits/is_specialized.pass.cpp b/test/language.support/support.limits/limits/is_specialized.pass.cpp
new file mode 100644
index 0000000..490289e
--- /dev/null
+++ b/test/language.support/support.limits/limits/is_specialized.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// Specializations shall be provided for each arithmetic type, both floating
+// point and integer, including bool. The member is_specialized shall be
+// true for all such specializations of numeric_limits.
+
+// Non-arithmetic standard types, such as complex<T> (26.3.2), shall not
+// have specializations.
+
+// From [numeric.limits]:
+
+// The value of each member of a specialization of numeric_limits on a cv
+// -qualified type cv T shall be equal to the value of the corresponding
+// member of the specialization on the unqualified type T.
+
+// More convenient to test it here.
+
+#include <limits>
+#include <complex>
+
+template <class T>
+void test()
+{
+    static_assert(std::numeric_limits<T>::is_specialized,
+                 "std::numeric_limits<T>::is_specialized");
+    static_assert(std::numeric_limits<const T>::is_specialized,
+                 "std::numeric_limits<const T>::is_specialized");
+    static_assert(std::numeric_limits<volatile T>::is_specialized,
+                 "std::numeric_limits<volatile T>::is_specialized");
+    static_assert(std::numeric_limits<const volatile T>::is_specialized,
+                 "std::numeric_limits<const volatile T>::is_specialized");
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif
+    test<signed char>();
+    test<unsigned char>();
+    test<signed short>();
+    test<unsigned short>();
+    test<signed int>();
+    test<unsigned int>();
+    test<signed long>();
+    test<unsigned long>();
+    test<signed long long>();
+    test<unsigned long long>();
+    test<float>();
+    test<double>();
+    test<long double>();
+    static_assert(!std::numeric_limits<std::complex<double> >::is_specialized,
+                 "!std::numeric_limits<std::complex<double> >::is_specialized");
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
new file mode 100644
index 0000000..101fa75
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// denorm_min()
+
+#include <limits>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::denorm_min() == expected);
+    assert(std::numeric_limits<const T>::denorm_min() == expected);
+    assert(std::numeric_limits<volatile T>::denorm_min() == expected);
+    assert(std::numeric_limits<const volatile T>::denorm_min() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+    test<float>(__FLT_DENORM_MIN__);
+    test<double>(__DBL_DENORM_MIN__);
+    test<long double>(__LDBL_DENORM_MIN__);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
new file mode 100644
index 0000000..58337ec
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::digits == expected, "digits test 1");
+    static_assert(std::numeric_limits<const T>::digits == expected, "digits test 2");
+    static_assert(std::numeric_limits<volatile T>::digits == expected, "digits test 3");
+    static_assert(std::numeric_limits<const volatile T>::digits == expected, "digits test 4");
+}
+
+int main()
+{
+    test<bool, 1>();
+    test<char, std::numeric_limits<char>::is_signed ? 7 : 8>();
+    test<signed char, 7>();
+    test<unsigned char, 8>();
+    test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? 31 : 32>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 16>();
+    test<char32_t, 32>();
+#endif
+    test<short, 15>();
+    test<unsigned short, 16>();
+    test<int, 31>();
+    test<unsigned int, 32>();
+    test<long, sizeof(long) == 4 ? 31 : 63>();
+    test<unsigned long, sizeof(long) == 4 ? 32 : 64>();
+    test<long long, 63>();
+    test<unsigned long long, 64>();
+    test<float, FLT_MANT_DIG>();
+    test<double, DBL_MANT_DIG>();
+    test<long double, LDBL_MANT_DIG>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
new file mode 100644
index 0000000..6012d23
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
+    static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
+    static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
+    static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
+    static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
+    static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
+    static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
+    static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 2>();
+    test<signed char, 2>();
+    test<unsigned char, 2>();
+    test<wchar_t, 9>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 4>();
+    test<char32_t, 9>();
+#endif
+    test<short, 4>();
+    test<unsigned short, 4>();
+    test<int, 9>();
+    test<unsigned int, 9>();
+    test<long, sizeof(long) == 4 ? 9 : 18>();
+    test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
+    test<long long, 18>();
+    test<unsigned long long, 19>();
+    test<float, FLT_DIG>();
+    test<double, DBL_DIG>();
+    test<long double, LDBL_DIG>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
new file mode 100644
index 0000000..0869f88
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// epsilon()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::epsilon() == expected);
+    assert(std::numeric_limits<const T>::epsilon() == expected);
+    assert(std::numeric_limits<volatile T>::epsilon() == expected);
+    assert(std::numeric_limits<const volatile T>::epsilon() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+    test<float>(FLT_EPSILON);
+    test<double>(DBL_EPSILON);
+    test<long double>(LDBL_EPSILON);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp
new file mode 100644
index 0000000..59c2626
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm
+
+#include <limits>
+
+template <class T, std::float_denorm_style expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1");
+    static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2");
+    static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4");
+}
+
+int main()
+{
+    test<bool, std::denorm_absent>();
+    test<char, std::denorm_absent>();
+    test<signed char, std::denorm_absent>();
+    test<unsigned char, std::denorm_absent>();
+    test<wchar_t, std::denorm_absent>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, std::denorm_absent>();
+    test<char32_t, std::denorm_absent>();
+#endif
+    test<short, std::denorm_absent>();
+    test<unsigned short, std::denorm_absent>();
+    test<int, std::denorm_absent>();
+    test<unsigned int, std::denorm_absent>();
+    test<long, std::denorm_absent>();
+    test<unsigned long, std::denorm_absent>();
+    test<long long, std::denorm_absent>();
+    test<unsigned long long, std::denorm_absent>();
+    test<float, std::denorm_present>();
+    test<double, std::denorm_present>();
+    test<long double, std::denorm_present>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp
new file mode 100644
index 0000000..3e23b95
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm_loss
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_denorm_loss == expected, "has_denorm_loss test 1");
+    static_assert(std::numeric_limits<const T>::has_denorm_loss == expected, "has_denorm_loss test 2");
+    static_assert(std::numeric_limits<volatile T>::has_denorm_loss == expected, "has_denorm_loss test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_denorm_loss == expected, "has_denorm_loss test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp
new file mode 100644
index 0000000..caf8ea3
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_infinity
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_infinity == expected, "has_infinity test 1");
+    static_assert(std::numeric_limits<const T>::has_infinity == expected, "has_infinity test 2");
+    static_assert(std::numeric_limits<volatile T>::has_infinity == expected, "has_infinity test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_infinity == expected, "has_infinity test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp
new file mode 100644
index 0000000..b3b2d63
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_quiet_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_quiet_NaN == expected, "has_quiet_NaN test 1");
+    static_assert(std::numeric_limits<const T>::has_quiet_NaN == expected, "has_quiet_NaN test 2");
+    static_assert(std::numeric_limits<volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp
new file mode 100644
index 0000000..28beab8
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_signaling_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1");
+    static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2");
+    static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
new file mode 100644
index 0000000..2703366
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// infinity()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::infinity() == expected);
+    assert(std::numeric_limits<const T>::infinity() == expected);
+    assert(std::numeric_limits<volatile T>::infinity() == expected);
+    assert(std::numeric_limits<const volatile T>::infinity() == expected);
+}
+
+extern float zero;
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+    test<float>(1./zero);
+    test<double>(1./zero);
+    test<long double>(1./zero);
+}
+
+float zero = 0;
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp
new file mode 100644
index 0000000..e92b6df
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_bounded
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_bounded == expected, "is_bounded test 1");
+    static_assert(std::numeric_limits<const T>::is_bounded == expected, "is_bounded test 2");
+    static_assert(std::numeric_limits<volatile T>::is_bounded == expected, "is_bounded test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_bounded == expected, "is_bounded test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp
new file mode 100644
index 0000000..3c41e9b
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_exact.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_exact
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_exact == expected, "is_exact test 1");
+    static_assert(std::numeric_limits<const T>::is_exact == expected, "is_exact test 2");
+    static_assert(std::numeric_limits<volatile T>::is_exact == expected, "is_exact test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_exact == expected, "is_exact test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp
new file mode 100644
index 0000000..21574a2
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_iec559
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_iec559 == expected, "is_iec559 test 1");
+    static_assert(std::numeric_limits<const T>::is_iec559 == expected, "is_iec559 test 2");
+    static_assert(std::numeric_limits<volatile T>::is_iec559 == expected, "is_iec559 test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_iec559 == expected, "is_iec559 test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp
new file mode 100644
index 0000000..1c44d3f
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_integer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_integer
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_integer == expected, "is_integer test 1");
+    static_assert(std::numeric_limits<const T>::is_integer == expected, "is_integer test 2");
+    static_assert(std::numeric_limits<volatile T>::is_integer == expected, "is_integer test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_integer == expected, "is_integer test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
new file mode 100644
index 0000000..4bb8cae
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_modulo
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_modulo == expected, "is_modulo test 1");
+    static_assert(std::numeric_limits<const T>::is_modulo == expected, "is_modulo test 2");
+    static_assert(std::numeric_limits<volatile T>::is_modulo == expected, "is_modulo test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_modulo == expected, "is_modulo test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp
new file mode 100644
index 0000000..7ef84b0
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/is_signed.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_signed
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_signed == expected, "is_signed test 1");
+    static_assert(std::numeric_limits<const T>::is_signed == expected, "is_signed test 2");
+    static_assert(std::numeric_limits<volatile T>::is_signed == expected, "is_signed test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_signed == expected, "is_signed test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, char(-1) < char(0)>();
+    test<signed char, true>();
+    test<unsigned char, false>();
+    test<wchar_t, wchar_t(-1) < wchar_t(0)>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, true>();
+    test<unsigned short, false>();
+    test<int, true>();
+    test<unsigned int, false>();
+    test<long, true>();
+    test<unsigned long, false>();
+    test<long long, true>();
+    test<unsigned long long, false>();
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp
new file mode 100644
index 0000000..8a0a3b3
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/lowest.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// lowest()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::lowest() == expected);
+    assert(std::numeric_limits<T>::is_bounded);
+    assert(std::numeric_limits<const T>::lowest() == expected);
+    assert(std::numeric_limits<const T>::is_bounded);
+    assert(std::numeric_limits<volatile T>::lowest() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded);
+    assert(std::numeric_limits<const volatile T>::lowest() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(CHAR_MIN);
+    test<signed char>(SCHAR_MIN);
+    test<unsigned char>(0);
+    test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(SHRT_MIN);
+    test<unsigned short>(0);
+    test<int>(INT_MIN);
+    test<unsigned int>(0);
+    test<long>(LONG_MIN);
+    test<unsigned long>(0);
+    test<long long>(LLONG_MIN);
+    test<unsigned long long>(0);
+    test<float>(-FLT_MAX);
+    test<double>(-DBL_MAX);
+    test<long double>(-LDBL_MAX);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp
new file mode 100644
index 0000000..2cdbec8
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/max.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::max() == expected);
+    assert(std::numeric_limits<T>::is_bounded);
+    assert(std::numeric_limits<const T>::max() == expected);
+    assert(std::numeric_limits<const T>::is_bounded);
+    assert(std::numeric_limits<volatile T>::max() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded);
+    assert(std::numeric_limits<const volatile T>::max() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+    test<bool>(true);
+    test<char>(CHAR_MAX);
+    test<signed char>(SCHAR_MAX);
+    test<unsigned char>(UCHAR_MAX);
+    test<wchar_t>(WCHAR_MAX);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(USHRT_MAX);
+    test<char32_t>(UINT_MAX);
+#endif
+    test<short>(SHRT_MAX);
+    test<unsigned short>(USHRT_MAX);
+    test<int>(INT_MAX);
+    test<unsigned int>(UINT_MAX);
+    test<long>(LONG_MAX);
+    test<unsigned long>(ULONG_MAX);
+    test<long long>(LLONG_MAX);
+    test<unsigned long long>(ULLONG_MAX);
+    test<float>(FLT_MAX);
+    test<double>(DBL_MAX);
+    test<long double>(LDBL_MAX);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
new file mode 100644
index 0000000..f4faa6b
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_digits10 == expected, "max_digits10 test 1");
+    static_assert(std::numeric_limits<const T>::max_digits10 == expected, "max_digits10 test 2");
+    static_assert(std::numeric_limits<volatile T>::max_digits10 == expected, "max_digits10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_digits10 == expected, "max_digits10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+    test<float, 2+(FLT_MANT_DIG * 30103)/100000>();
+    test<double, 2+(DBL_MANT_DIG * 30103)/100000>();
+    test<long double, 2+(LDBL_MANT_DIG * 30103)/100000>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
new file mode 100644
index 0000000..b6c222b
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_exponent == expected, "max_exponent test 1");
+    static_assert(std::numeric_limits<const T>::max_exponent == expected, "max_exponent test 2");
+    static_assert(std::numeric_limits<volatile T>::max_exponent == expected, "max_exponent test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_exponent == expected, "max_exponent test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+    test<float, FLT_MAX_EXP>();
+    test<double, DBL_MAX_EXP>();
+    test<long double, LDBL_MAX_EXP>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
new file mode 100644
index 0000000..0df080a
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_exponent10 == expected, "max_exponent10 test 1");
+    static_assert(std::numeric_limits<const T>::max_exponent10 == expected, "max_exponent10 test 2");
+    static_assert(std::numeric_limits<volatile T>::max_exponent10 == expected, "max_exponent10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_exponent10 == expected, "max_exponent10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+    test<float, FLT_MAX_10_EXP>();
+    test<double, DBL_MAX_10_EXP>();
+    test<long double, LDBL_MAX_10_EXP>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp
new file mode 100644
index 0000000..f67fa9e
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/min.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::min() == expected);
+    assert(std::numeric_limits<T>::is_bounded || !std::numeric_limits<T>::is_signed);
+    assert(std::numeric_limits<const T>::min() == expected);
+    assert(std::numeric_limits<const T>::is_bounded || !std::numeric_limits<const T>::is_signed);
+    assert(std::numeric_limits<volatile T>::min() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded || !std::numeric_limits<volatile T>::is_signed);
+    assert(std::numeric_limits<const volatile T>::min() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded || !std::numeric_limits<const volatile T>::is_signed);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(CHAR_MIN);
+    test<signed char>(SCHAR_MIN);
+    test<unsigned char>(0);
+    test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(SHRT_MIN);
+    test<unsigned short>(0);
+    test<int>(INT_MIN);
+    test<unsigned int>(0);
+    test<long>(LONG_MIN);
+    test<unsigned long>(0);
+    test<long long>(LLONG_MIN);
+    test<unsigned long long>(0);
+    test<float>(FLT_MIN);
+    test<double>(DBL_MIN);
+    test<long double>(LDBL_MIN);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
new file mode 100644
index 0000000..531d25a
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::min_exponent == expected, "min_exponent test 1");
+    static_assert(std::numeric_limits<const T>::min_exponent == expected, "min_exponent test 2");
+    static_assert(std::numeric_limits<volatile T>::min_exponent == expected, "min_exponent test 3");
+    static_assert(std::numeric_limits<const volatile T>::min_exponent == expected, "min_exponent test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+    test<float, FLT_MIN_EXP>();
+    test<double, DBL_MIN_EXP>();
+    test<long double, LDBL_MIN_EXP>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
new file mode 100644
index 0000000..5f335fe
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::min_exponent10 == expected, "min_exponent10 test 1");
+    static_assert(std::numeric_limits<const T>::min_exponent10 == expected, "min_exponent10 test 2");
+    static_assert(std::numeric_limits<volatile T>::min_exponent10 == expected, "min_exponent10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::min_exponent10 == expected, "min_exponent10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+    test<float, FLT_MIN_10_EXP>();
+    test<double, DBL_MIN_10_EXP>();
+    test<long double, LDBL_MIN_10_EXP>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp
new file mode 100644
index 0000000..7ce5130
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// quiet_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+    assert(std::isnan(std::numeric_limits<T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<const T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<volatile T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<const volatile T>::quiet_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+    assert(std::numeric_limits<T>::quiet_NaN() == T());
+    assert(std::numeric_limits<const T>::quiet_NaN() == T());
+    assert(std::numeric_limits<volatile T>::quiet_NaN() == T());
+    assert(std::numeric_limits<const volatile T>::quiet_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+    test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
new file mode 100644
index 0000000..b9f1f0c
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// radix
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::radix == expected, "radix test 1");
+    static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2");
+    static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3");
+    static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4");
+}
+
+int main()
+{
+    test<bool, 2>();
+    test<char, 2>();
+    test<signed char, 2>();
+    test<unsigned char, 2>();
+    test<wchar_t, 2>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 2>();
+    test<char32_t, 2>();
+#endif
+    test<short, 2>();
+    test<unsigned short, 2>();
+    test<int, 2>();
+    test<unsigned int, 2>();
+    test<long, 2>();
+    test<unsigned long, 2>();
+    test<long long, 2>();
+    test<unsigned long long, 2>();
+    test<float, FLT_RADIX>();
+    test<double, FLT_RADIX>();
+    test<long double, FLT_RADIX>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
new file mode 100644
index 0000000..19c22b8
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_error()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::round_error() == expected);
+    assert(std::numeric_limits<const T>::round_error() == expected);
+    assert(std::numeric_limits<volatile T>::round_error() == expected);
+    assert(std::numeric_limits<const volatile T>::round_error() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+    test<float>(0.5);
+    test<double>(0.5);
+    test<long double>(0.5);
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp
new file mode 100644
index 0000000..d0c7259
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/round_style.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_style
+
+#include <limits>
+
+template <class T, std::float_round_style expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::round_style == expected, "round_style test 1");
+    static_assert(std::numeric_limits<const T>::round_style == expected, "round_style test 2");
+    static_assert(std::numeric_limits<volatile T>::round_style == expected, "round_style test 3");
+    static_assert(std::numeric_limits<const volatile T>::round_style == expected, "round_style test 4");
+}
+
+int main()
+{
+    test<bool, std::round_toward_zero>();
+    test<char, std::round_toward_zero>();
+    test<signed char, std::round_toward_zero>();
+    test<unsigned char, std::round_toward_zero>();
+    test<wchar_t, std::round_toward_zero>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, std::round_toward_zero>();
+    test<char32_t, std::round_toward_zero>();
+#endif
+    test<short, std::round_toward_zero>();
+    test<unsigned short, std::round_toward_zero>();
+    test<int, std::round_toward_zero>();
+    test<unsigned int, std::round_toward_zero>();
+    test<long, std::round_toward_zero>();
+    test<unsigned long, std::round_toward_zero>();
+    test<long long, std::round_toward_zero>();
+    test<unsigned long long, std::round_toward_zero>();
+    test<float, std::round_to_nearest>();
+    test<double, std::round_to_nearest>();
+    test<long double, std::round_to_nearest>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp
new file mode 100644
index 0000000..8acd6b8
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// signaling_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+    assert(std::isnan(std::numeric_limits<T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<const T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<volatile T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<const volatile T>::signaling_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+    assert(std::numeric_limits<T>::signaling_NaN() == T());
+    assert(std::numeric_limits<const T>::signaling_NaN() == T());
+    assert(std::numeric_limits<volatile T>::signaling_NaN() == T());
+    assert(std::numeric_limits<const volatile T>::signaling_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+    test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
new file mode 100644
index 0000000..8c3fbd0
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// tinyness_before
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::tinyness_before == expected, "tinyness_before test 1");
+    static_assert(std::numeric_limits<const T>::tinyness_before == expected, "tinyness_before test 2");
+    static_assert(std::numeric_limits<volatile T>::tinyness_before == expected, "tinyness_before test 3");
+    static_assert(std::numeric_limits<const volatile T>::tinyness_before == expected, "tinyness_before test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp b/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
new file mode 100644
index 0000000..2b8d167
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits.members/traps.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// traps
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
+    static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
+    static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
+    static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp b/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp
new file mode 100644
index 0000000..c9d07de
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// The default numeric_limits<T> template shall have all members, but with
+// 0 or false values.
+
+#include <limits>
+#include <cassert>
+
+struct A
+{
+    A(int i = 0) : data_(i) {}
+    int data_;
+};
+
+bool operator == (const A& x, const A& y) {return x.data_ == y.data_;}
+
+int main()
+{
+    static_assert(std::numeric_limits<A>::is_specialized == false,
+                 "std::numeric_limits<A>::is_specialized == false");
+    assert(std::numeric_limits<A>::min() == A());
+    assert(std::numeric_limits<A>::max() == A());
+    assert(std::numeric_limits<A>::lowest() == A());
+    static_assert(std::numeric_limits<A>::digits == 0,
+                 "std::numeric_limits<A>::digits == 0");
+    static_assert(std::numeric_limits<A>::digits10 == 0,
+                 "std::numeric_limits<A>::digits10 == 0");
+    static_assert(std::numeric_limits<A>::max_digits10 == 0,
+                 "std::numeric_limits<A>::max_digits10 == 0");
+    static_assert(std::numeric_limits<A>::is_signed == false,
+                 "std::numeric_limits<A>::is_signed == false");
+    static_assert(std::numeric_limits<A>::is_integer == false,
+                 "std::numeric_limits<A>::is_integer == false");
+    static_assert(std::numeric_limits<A>::is_exact == false,
+                 "std::numeric_limits<A>::is_exact == false");
+    static_assert(std::numeric_limits<A>::radix == 0,
+                 "std::numeric_limits<A>::radix == 0");
+    assert(std::numeric_limits<A>::epsilon() == A());
+    assert(std::numeric_limits<A>::round_error() == A());
+    static_assert(std::numeric_limits<A>::min_exponent == 0,
+                 "std::numeric_limits<A>::min_exponent == 0");
+    static_assert(std::numeric_limits<A>::min_exponent10 == 0,
+                 "std::numeric_limits<A>::min_exponent10 == 0");
+    static_assert(std::numeric_limits<A>::max_exponent == 0,
+                 "std::numeric_limits<A>::max_exponent == 0");
+    static_assert(std::numeric_limits<A>::max_exponent10 == 0,
+                 "std::numeric_limits<A>::max_exponent10 == 0");
+    static_assert(std::numeric_limits<A>::has_infinity == false,
+                 "std::numeric_limits<A>::has_infinity == false");
+    static_assert(std::numeric_limits<A>::has_quiet_NaN == false,
+                 "std::numeric_limits<A>::has_quiet_NaN == false");
+    static_assert(std::numeric_limits<A>::has_signaling_NaN == false,
+                 "std::numeric_limits<A>::has_signaling_NaN == false");
+    static_assert(std::numeric_limits<A>::has_denorm == std::denorm_absent,
+                 "std::numeric_limits<A>::has_denorm == std::denorm_absent");
+    static_assert(std::numeric_limits<A>::has_denorm_loss == false,
+                 "std::numeric_limits<A>::has_denorm_loss == false");
+    assert(std::numeric_limits<A>::infinity() == A());
+    assert(std::numeric_limits<A>::quiet_NaN() == A());
+    assert(std::numeric_limits<A>::signaling_NaN() == A());
+    assert(std::numeric_limits<A>::denorm_min() == A());
+    static_assert(std::numeric_limits<A>::is_iec559 == false,
+                 "std::numeric_limits<A>::is_iec559 == false");
+    static_assert(std::numeric_limits<A>::is_bounded == false,
+                 "std::numeric_limits<A>::is_bounded == false");
+    static_assert(std::numeric_limits<A>::is_modulo == false,
+                 "std::numeric_limits<A>::is_modulo == false");
+    static_assert(std::numeric_limits<A>::traps == false,
+                 "std::numeric_limits<A>::traps == false");
+    static_assert(std::numeric_limits<A>::tinyness_before == false,
+                 "std::numeric_limits<A>::tinyness_before == false");
+    static_assert(std::numeric_limits<A>::round_style == std::round_toward_zero,
+                 "std::numeric_limits<A>::round_style == std::round_toward_zero");
+}
diff --git a/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp b/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/limits/round.style/check_values.pass.cpp b/test/language.support/support.limits/limits/round.style/check_values.pass.cpp
new file mode 100644
index 0000000..36299d7
--- /dev/null
+++ b/test/language.support/support.limits/limits/round.style/check_values.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_denorm_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_denorm_style);
+two test(int);
+
+int main()
+{
+    static_assert(std::denorm_indeterminate == -1,
+                 "std::denorm_indeterminate == -1");
+    static_assert(std::denorm_absent == 0,
+                 "std::denorm_absent == 0");
+    static_assert(std::denorm_present == 1,
+                 "std::denorm_present == 1");
+    static_assert(sizeof(test(std::denorm_present)) == 1,
+                 "sizeof(test(std::denorm_present)) == 1");
+    static_assert(sizeof(test(1)) == 2,
+                 "sizeof(test(1)) == 2");
+}
diff --git a/test/language.support/support.limits/limits/version.pass.cpp b/test/language.support/support.limits/limits/version.pass.cpp
new file mode 100644
index 0000000..5aa25cd
--- /dev/null
+++ b/test/language.support/support.limits/limits/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <limits>
+
+#include <limits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.limits/nothing_to_do.pass.cpp b/test/language.support/support.limits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/language.support/support.limits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
new file mode 100644
index 0000000..a4ce418
--- /dev/null
+++ b/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_cast
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_cast>::value),
+                 "std::is_base_of<std::exception, std::bad_cast>::value");
+    static_assert(std::is_polymorphic<std::bad_cast>::value,
+                 "std::is_polymorphic<std::bad_cast>::value");
+    std::bad_cast b;
+    std::bad_cast b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
new file mode 100644
index 0000000..7f4f818
--- /dev/null
+++ b/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_typeid
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_typeid>::value),
+                 "std::is_base_of<std::exception, std::bad_typeid>::value");
+    static_assert(std::is_polymorphic<std::bad_typeid>::value,
+                 "std::is_polymorphic<std::bad_typeid>::value");
+    std::bad_typeid b;
+    std::bad_typeid b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/test/language.support/support.rtti/type.info/type_info.pass.cpp b/test/language.support/support.rtti/type.info/type_info.pass.cpp
new file mode 100644
index 0000000..d20f524
--- /dev/null
+++ b/test/language.support/support.rtti/type.info/type_info.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& t1 = typeid(int);
+    const std::type_info& t2 = typeid(int);
+    assert(t1 == t2);
+    const std::type_info& t3 = typeid(short);
+    assert(t1 != t3);
+    assert(!t1.before(t2));
+    assert(strcmp(t1.name(), t2.name()) == 0);
+    assert(strcmp(t1.name(), t3.name()) != 0);
+}
diff --git a/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp
new file mode 100644
index 0000000..00178e1
--- /dev/null
+++ b/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& t1 = typeid(int);
+    const std::type_info& t2 = typeid(int);
+    const std::type_info& t3 = typeid(short);
+    assert(t1.hash_code() == t2.hash_code());
+    assert(t1.hash_code() != t3.hash_code());
+}
diff --git a/test/language.support/support.rtti/version.pass.cpp b/test/language.support/support.rtti/version.pass.cpp
new file mode 100644
index 0000000..cd8fdaf
--- /dev/null
+++ b/test/language.support/support.rtti/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeinfo>
+
+#include <typeinfo>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/csetjmp.pass.cpp b/test/language.support/support.runtime/csetjmp.pass.cpp
new file mode 100644
index 0000000..c57bab9
--- /dev/null
+++ b/test/language.support/support.runtime/csetjmp.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csetjmp>
+
+#include <csetjmp>
+#include <type_traits>
+
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
+int main()
+{
+    std::jmp_buf jb;
+    static_assert((std::is_same<__typeof__(std::longjmp(jb, 0)), void>::value),
+                  "std::is_same<__typeof__(std::longjmp(jb, 0)), void>::value");
+}
diff --git a/test/language.support/support.runtime/csignal.pass.cpp b/test/language.support/support.runtime/csignal.pass.cpp
new file mode 100644
index 0000000..0dcabb0
--- /dev/null
+++ b/test/language.support/support.runtime/csignal.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csignal>
+
+#include <csignal>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+    std::sig_atomic_t sig;
+    typedef void (*func)(int);
+    static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), "");
+    static_assert((std::is_same<decltype(std::raise(0)), int>::value), "");
+}
diff --git a/test/language.support/support.runtime/cstdarg.pass.cpp b/test/language.support/support.runtime/cstdarg.pass.cpp
new file mode 100644
index 0000000..f25bdb6
--- /dev/null
+++ b/test/language.support/support.runtime/cstdarg.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdarg>
+
+#include <cstdarg>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#ifndef va_copy
+#error va_copy not defined
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+    std::va_list va;
+}
diff --git a/test/language.support/support.runtime/cstdbool.pass.cpp b/test/language.support/support.runtime/cstdbool.pass.cpp
new file mode 100644
index 0000000..7d4dcd2
--- /dev/null
+++ b/test/language.support/support.runtime/cstdbool.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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdbool>
+
+#include <cstdbool>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/cstdlib.pass.cpp b/test/language.support/support.runtime/cstdlib.pass.cpp
new file mode 100644
index 0000000..3e42f8c
--- /dev/null
+++ b/test/language.support/support.runtime/cstdlib.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdlib>
+
+#include <cstdlib>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+    std::size_t s = 0;
+    std::div_t d;
+    std::ldiv_t ld;
+    std::lldiv_t lld;
+    char** endptr = 0;
+    static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
+    static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::atol("")), long>::value), "");
+    static_assert((std::is_same<decltype(std::atoll("")), long long>::value), "");
+    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strtod("", endptr)), double>::value), "");
+    static_assert((std::is_same<decltype(std::strtof("", endptr)), float>::value), "");
+    static_assert((std::is_same<decltype(std::strtold("", endptr)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::strtol("", endptr,0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoll("", endptr,0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoul("", endptr,0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoull("", endptr,0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(std::rand()), int>::value), "");
+    static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::free(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::malloc(0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::realloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::abort()), void>::value), "");
+    static_assert((std::is_same<decltype(std::atexit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::_Exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(std::system("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::bsearch(0,0,0,0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::qsort(0,0,0,0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::abs(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::labs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::llabs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::div(0,0)), std::div_t>::value), "");
+    static_assert((std::is_same<decltype(std::div(0L,0L)), std::ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::div(0LL,0LL)), std::lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::ldiv(0L,0L)), std::ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::lldiv(0LL,0LL)), std::lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::mblen("",0)), int>::value), "");
+    wchar_t* pw = 0;
+    const wchar_t* pwc = 0;
+    char* pc = 0;
+    static_assert((std::is_same<decltype(std::mbtowc(pw,"",0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wctomb(pc,L' ')), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbstowcs(pw,"",0)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstombs(pc,pwc,0)), std::size_t>::value), "");
+}
diff --git a/test/language.support/support.runtime/ctime.pass.cpp b/test/language.support/support.runtime/ctime.pass.cpp
new file mode 100644
index 0000000..4b20576
--- /dev/null
+++ b/test/language.support/support.runtime/ctime.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test <ctime>
+
+#include <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    std::clock_t c = 0;
+    std::size_t s = 0;
+    std::time_t t = 0;
+    std::tm tm = {0};
+    static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+    static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+    char* c1 = 0;
+    const char* c2 = 0;
+    static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), "");
+}
diff --git a/test/language.support/support.runtime/version_csetjmp.pass.cpp b/test/language.support/support.runtime/version_csetjmp.pass.cpp
new file mode 100644
index 0000000..6607f7d
--- /dev/null
+++ b/test/language.support/support.runtime/version_csetjmp.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <csetjmp>
+
+#include <csetjmp>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/version_csignal.pass.cpp b/test/language.support/support.runtime/version_csignal.pass.cpp
new file mode 100644
index 0000000..5d4a38e
--- /dev/null
+++ b/test/language.support/support.runtime/version_csignal.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <csignal>
+
+#include <csignal>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/version_cstdarg.pass.cpp b/test/language.support/support.runtime/version_cstdarg.pass.cpp
new file mode 100644
index 0000000..16e2e9e
--- /dev/null
+++ b/test/language.support/support.runtime/version_cstdarg.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdarg>
+
+#include <cstdarg>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/version_cstdbool.pass.cpp b/test/language.support/support.runtime/version_cstdbool.pass.cpp
new file mode 100644
index 0000000..2eab23b
--- /dev/null
+++ b/test/language.support/support.runtime/version_cstdbool.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdbool>
+
+#include <cstdbool>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/version_cstdlib.pass.cpp b/test/language.support/support.runtime/version_cstdlib.pass.cpp
new file mode 100644
index 0000000..7de7169
--- /dev/null
+++ b/test/language.support/support.runtime/version_cstdlib.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib>
+
+#include <cstdlib>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.runtime/version_ctime.pass.cpp b/test/language.support/support.runtime/version_ctime.pass.cpp
new file mode 100644
index 0000000..659d85e
--- /dev/null
+++ b/test/language.support/support.runtime/version_ctime.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctime>
+
+#include <ctime>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.start.term/quick_exit.pass.cpp b/test/language.support/support.start.term/quick_exit.pass.cpp
new file mode 100644
index 0000000..aa474c1
--- /dev/null
+++ b/test/language.support/support.start.term/quick_exit.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test quick_exit and at_quick_exit
+
+#include <cstdlib>
+#include <type_traits>
+
+void f();
+
+int main()
+{
+    std::at_quick_exit(f);
+    quick_exit(0);
+}
diff --git a/test/language.support/support.types/max_align_t.pass.cpp b/test/language.support/support.types/max_align_t.pass.cpp
new file mode 100644
index 0000000..d9a0d98
--- /dev/null
+++ b/test/language.support/support.types/max_align_t.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// max_align_t is a POD type whose alignment requirement is at least as
+//   great as that of every scalar type
+
+#include <stdio.h>
+
+int main()
+{
+    static_assert(std::is_pod<std::max_align_t>::value,
+                  "std::is_pod<std::max_align_t>::value");
+    static_assert((std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<long long>::value),
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<long long>::value");
+    static_assert(std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<long double>::value,
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<long double>::value");
+    static_assert(std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<void*>::value,
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<void*>::value");
+}
diff --git a/test/language.support/support.types/null.pass.cpp b/test/language.support/support.types/null.pass.cpp
new file mode 100644
index 0000000..563b616
--- /dev/null
+++ b/test/language.support/support.types/null.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.types/nullptr_t.pass.cpp b/test/language.support/support.types/nullptr_t.pass.cpp
new file mode 100644
index 0000000..ec1059b
--- /dev/null
+++ b/test/language.support/support.types/nullptr_t.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+#include <cassert>
+
+// typedef decltype(nullptr) nullptr_t;
+
+struct A
+{
+    A(std::nullptr_t) {}
+};
+
+int main()
+{
+    static_assert(sizeof(std::nullptr_t) == sizeof(void*),
+                  "sizeof(std::nullptr_t) == sizeof(void*)");
+    A* p = 0;
+    assert(p == nullptr);
+    void (A::*pmf)() = 0;
+#ifdef __clang__
+    // GCC 4.2 can't handle this
+    assert(pmf == nullptr);
+#endif
+    int A::*pmd = 0;
+    assert(pmd == nullptr);
+    A a1(nullptr);
+    A a2(0);
+    bool b = nullptr;
+    assert(!b);
+    assert(nullptr == nullptr);
+    assert(nullptr <= nullptr);
+    assert(nullptr >= nullptr);
+    assert(!(nullptr != nullptr));
+    assert(!(nullptr < nullptr));
+    assert(!(nullptr > nullptr));
+}
diff --git a/test/language.support/support.types/offsetof.pass.cpp b/test/language.support/support.types/offsetof.pass.cpp
new file mode 100644
index 0000000..b551ea5
--- /dev/null
+++ b/test/language.support/support.types/offsetof.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/language.support/support.types/ptrdiff_t.pass.cpp b/test/language.support/support.types/ptrdiff_t.pass.cpp
new file mode 100644
index 0000000..cffef94
--- /dev/null
+++ b/test/language.support/support.types/ptrdiff_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// ptrdiff_t should:
+
+//  1. be in namespace std.
+//  2. be the same sizeof as void*.
+//  3. be a signed integral.
+
+int main()
+{
+    static_assert(sizeof(std::ptrdiff_t) == sizeof(void*),
+                  "sizeof(std::ptrdiff_t) == sizeof(void*)");
+    static_assert(std::is_signed<std::ptrdiff_t>::value,
+                  "std::is_signed<std::ptrdiff_t>::value");
+    static_assert(std::is_integral<std::ptrdiff_t>::value,
+                  "std::is_integral<std::ptrdiff_t>::value");
+}
diff --git a/test/language.support/support.types/size_t.pass.cpp b/test/language.support/support.types/size_t.pass.cpp
new file mode 100644
index 0000000..d8de688
--- /dev/null
+++ b/test/language.support/support.types/size_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstddef>
+#include <type_traits>
+
+// size_t should:
+
+//  1. be in namespace std.
+//  2. be the same sizeof as void*.
+//  3. be an unsigned integral.
+
+int main()
+{
+    static_assert(sizeof(std::size_t) == sizeof(void*),
+                  "sizeof(std::size_t) == sizeof(void*)");
+    static_assert(std::is_unsigned<std::size_t>::value,
+                  "std::is_unsigned<std::size_t>::value");
+    static_assert(std::is_integral<std::size_t>::value,
+                  "std::is_integral<std::size_t>::value");
+}
diff --git a/test/language.support/support.types/version.pass.cpp b/test/language.support/support.types/version.pass.cpp
new file mode 100644
index 0000000..8eb0a1c
--- /dev/null
+++ b/test/language.support/support.types/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstddef>
+
+#include <cstddef>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/localization/c.locales/clocale.pass.cpp b/test/localization/c.locales/clocale.pass.cpp
new file mode 100644
index 0000000..8e949ea
--- /dev/null
+++ b/test/localization/c.locales/clocale.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+#include <type_traits>
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    std::lconv lc;
+    static_assert((std::is_same<__typeof__(std::setlocale(0, "")), char*>::value), "");
+    static_assert((std::is_same<__typeof__(std::localeconv()), std::lconv*>::value), "");
+}
diff --git a/test/localization/c.locales/version.pass.cpp b/test/localization/c.locales/version.pass.cpp
new file mode 100644
index 0000000..e6b4be8
--- /dev/null
+++ b/test/localization/c.locales/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/__scan_keyword.pass.cpp b/test/localization/locale.categories/__scan_keyword.pass.cpp
new file mode 100644
index 0000000..60da89d
--- /dev/null
+++ b/test/localization/locale.categories/__scan_keyword.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// Not a portable test
+
+// __scan_keyword
+// Scans [__b, __e) until a match is found in the basic_strings range
+//  [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+//  __b will be incremented (visibly), consuming CharT until a match is found
+//  or proved to not exist.  A keyword may be "", in which will match anything.
+//  If one keyword is a prefix of another, and the next CharT in the input
+//  might match another keyword, the algorithm will attempt to find the longest
+//  matching keyword.  If the longer matching keyword ends up not matching, then
+//  no keyword match is found.  If no keyword match is found, __ke is returned.
+//  Else an iterator pointing to the matching keyword is found.  If more than
+//  one keyword matches, an iterator to the first matching keyword is returned.
+//  If on exit __b == __e, eofbit is set in __err.  If __case_senstive is false,
+//  __ct is used to force to lower case before comparing characters.
+//  Examples:
+//  Keywords:  "a", "abb"
+//  If the input is "a", the first keyword matches and eofbit is set.
+//  If the input is "abc", no match is found and "ab" are consumed.
+//
+// template <class _InputIterator, class _ForwardIterator, class _Ctype>
+// _ForwardIterator
+// __scan_keyword(_InputIterator& __b, _InputIterator __e,
+//                _ForwardIterator __kb, _ForwardIterator __ke,
+//                const _Ctype& __ct, ios_base::iostate& __err,
+//                bool __case_sensitive = true);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
+    std::ios_base::iostate err = std::ios_base::goodbit;
+    {
+        const char input[] = "a";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 0);
+        assert(in == input+1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char input[] = "abc";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 2);
+        assert(in == input+2);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char input[] = "abb";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 1);
+        assert(in == input+3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char input[] = "Tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 2);
+        assert(in == input+3);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char input[] = "tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 4);
+        assert(in == input+0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char input[] = "tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err, false);
+        assert(k - keys == 2);
+        assert(in == input+3);
+        assert(err == std::ios_base::goodbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
new file mode 100644
index 0000000..d8a7929
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// int compare(const charT* low1, const charT* high1, 
+//             const charT* low2, const charT* high2) const;
+
+//  I'm currently unable to confirm that collation based on named locales
+//     has any difference from "C" collation.  But I do believe I'm picking
+//     up the OS's collation files.
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+    {
+        std::locale l("");
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
new file mode 100644
index 0000000..6f1ce94
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// long hash(const charT* low, const charT* high) const;
+
+//   This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l("en_US");
+    {
+        std::string x1("1234");
+        std::string x2("12345");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+    {
+        std::wstring x1(L"1234");
+        std::wstring x2(L"12345");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
new file mode 100644
index 0000000..538a64e
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// string_type transform(const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+    }
+    {
+        std::locale l("");
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) == x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) == x);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
new file mode 100644
index 0000000..e819bf2
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> 
+// class collate_byname
+//     : public collate<charT>
+// {
+// public: 
+//     typedef basic_string<charT> string_type; 
+//     explicit collate_byname(const char*, size_t refs = 0); 
+//     explicit collate_byname(const string&, size_t refs = 0); 
+// protected: 
+//     ~collate_byname(); 
+// };
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l("en_US");
+    {
+        assert(std::has_facet<std::collate_byname<char> >(l));
+        assert(&std::use_facet<std::collate<char> >(l)
+            == &std::use_facet<std::collate_byname<char> >(l));
+    }
+    {
+        assert(std::has_facet<std::collate_byname<wchar_t> >(l));
+        assert(&std::use_facet<std::collate<wchar_t> >(l)
+            == &std::use_facet<std::collate_byname<wchar_t> >(l));
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp
new file mode 100644
index 0000000..07eece2
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/ctor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// explicit collate(size_t refs = 0);
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::collate<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::collate<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<char>);
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        my_facet<char> f(1);
+        assert(my_facet<char>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<char>::count == 1);
+        }
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
new file mode 100644
index 0000000..06785c3
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// int compare(const charT* low1, const charT* high1, 
+//             const charT* low2, const charT* high2) const;
+
+#include <locale>
+#include <cassert>
+
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        const char ia[] = "1234";
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        const char ib[] = "123";
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+        assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+        assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+        assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+        assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+    }
+    {
+        const wchar_t ia[] = L"1234";
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        const wchar_t ib[] = L"123";
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+        assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+        assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+        assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+        assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
new file mode 100644
index 0000000..8395945
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// long hash(const charT* low, const charT* high) const;
+
+//   This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        std::string x1("1234");
+        std::string x2("12345");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+    {
+        std::wstring x1(L"1234");
+        std::wstring x2(L"12345");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
new file mode 100644
index 0000000..6afcbaf
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// string_type transform(const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        std::string x("1234");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.transform(x.data(), x.data() + x.size()) == x);
+    }
+    {
+        std::wstring x(L"1234");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.transform(x.data(), x.data() + x.size()) == x);
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp b/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
new file mode 100644
index 0000000..bf0277f
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> 
+// class collate
+//     : public locale::facet { 
+// public: 
+//     typedef charT char_type; 
+//     typedef basic_string<charT>string_type;
+// 
+//     static locale::id id;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::collate<char> >(l));
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        {
+            (void)std::collate<char>::id;
+        }
+        static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
+        static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
+    }
+    {
+        assert(std::has_facet<std::collate<wchar_t> >(l));
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        {
+            (void)std::collate<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
+    }
+}
diff --git a/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp b/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp
new file mode 100644
index 0000000..fbe88a8
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class ctype_base
+// { 
+// public: 
+//     typedef T mask; 
+// 
+//     // numeric values are for exposition only. 
+//     static const mask space = 1 << 0; 
+//     static const mask print = 1 << 1; 
+//     static const mask cntrl = 1 << 2; 
+//     static const mask upper = 1 << 3; 
+//     static const mask lower = 1 << 4; 
+//     static const mask alpha = 1 << 5; 
+//     static const mask digit = 1 << 6; 
+//     static const mask punct = 1 << 7; 
+//     static const mask xdigit = 1 << 8; 
+//     static const mask alnum = alpha | digit; 
+//     static const mask graph = alnum | punct; 
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    assert(std::ctype_base::space);
+    assert(std::ctype_base::print);
+    assert(std::ctype_base::cntrl);
+    assert(std::ctype_base::upper);
+    assert(std::ctype_base::lower);
+    assert(std::ctype_base::alpha);
+    assert(std::ctype_base::digit);
+    assert(std::ctype_base::punct);
+    assert(std::ctype_base::xdigit);
+    assert(
+      ( std::ctype_base::space
+      & std::ctype_base::print
+      & std::ctype_base::cntrl
+      & std::ctype_base::upper
+      & std::ctype_base::lower
+      & std::ctype_base::alpha
+      & std::ctype_base::digit
+      & std::ctype_base::punct
+      & std::ctype_base::xdigit) == 0);
+    assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
+    assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
+}
\ No newline at end of file
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
new file mode 100644
index 0000000..bac1a3a
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// ~ctype();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+unsigned delete_called = 0;
+
+void operator delete[](void* p) throw()
+{
+    operator delete(p);
+    ++delete_called;
+}
+
+int main()
+{
+    {
+        delete_called = 0;
+        std::locale l(std::locale::classic(), new std::ctype<char>);
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 0);
+    {
+        std::ctype<char>::mask table[256];
+        delete_called = 0;
+        std::locale l(std::locale::classic(), new std::ctype<char>(table));
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 0);
+    {
+        delete_called = 0;
+        std::locale l(std::locale::classic(),
+            new std::ctype<char>(new std::ctype<char>::mask[256], true));
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 1);
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
new file mode 100644
index 0000000..bde9ebd
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+class my_facet
+    : public std::ctype<char>
+{
+public:
+    static int count;
+
+    explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0)
+        : std::ctype<char>(tbl, del, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(0, false, 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
new file mode 100644
index 0000000..eeddea8
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// bool is(mask m, char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.is(F::space, ' '));
+        assert(!f.is(F::space, 'A'));
+
+        assert(f.is(F::print, ' '));
+        assert(!f.is(F::print, '\x07'));
+
+        assert(f.is(F::cntrl, '\x07'));
+        assert(!f.is(F::cntrl, ' '));
+
+        assert(f.is(F::upper, 'A'));
+        assert(!f.is(F::upper, 'a'));
+
+        assert(f.is(F::lower, 'a'));
+        assert(!f.is(F::lower, 'A'));
+
+        assert(f.is(F::alpha, 'a'));
+        assert(!f.is(F::alpha, '1'));
+
+        assert(f.is(F::digit, '1'));
+        assert(!f.is(F::digit, 'a'));
+
+        assert(f.is(F::punct, '.'));
+        assert(!f.is(F::punct, 'a'));
+
+        assert(f.is(F::xdigit, 'a'));
+        assert(!f.is(F::xdigit, 'g'));
+
+        assert(f.is(F::alnum, 'a'));
+        assert(!f.is(F::alnum, '.'));
+
+        assert(f.is(F::graph, '.'));
+        assert(!f.is(F::graph,  '\x07'));
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
new file mode 100644
index 0000000..0c228c5
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* is(const char* low, const char* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        const char* h = f.is(in.data(), in.data() + in.size(), m.data());
+        assert(h == in.data() + in.size());
+
+        // ' '
+        assert( (m[0] & F::space));
+        assert( (m[0] & F::print));
+        assert(!(m[0] & F::cntrl));
+        assert(!(m[0] & F::upper));
+        assert(!(m[0] & F::lower));
+        assert(!(m[0] & F::alpha));
+        assert(!(m[0] & F::digit));
+        assert(!(m[0] & F::punct));
+        assert(!(m[0] & F::xdigit));
+        assert( (m[0] & F::blank));
+        assert(!(m[0] & F::alnum));
+        assert(!(m[0] & F::graph));
+
+        // 'A'
+        assert(!(m[1] & F::space));
+        assert( (m[1] & F::print));
+        assert(!(m[1] & F::cntrl));
+        assert( (m[1] & F::upper));
+        assert(!(m[1] & F::lower));
+        assert( (m[1] & F::alpha));
+        assert(!(m[1] & F::digit));
+        assert(!(m[1] & F::punct));
+        assert( (m[1] & F::xdigit));
+        assert(!(m[1] & F::blank));
+        assert( (m[1] & F::alnum));
+        assert( (m[1] & F::graph));
+
+        // '\x07'
+        assert(!(m[2] & F::space));
+        assert(!(m[2] & F::print));
+        assert( (m[2] & F::cntrl));
+        assert(!(m[2] & F::upper));
+        assert(!(m[2] & F::lower));
+        assert(!(m[2] & F::alpha));
+        assert(!(m[2] & F::digit));
+        assert(!(m[2] & F::punct));
+        assert(!(m[2] & F::xdigit));
+        assert(!(m[2] & F::blank));
+        assert(!(m[2] & F::alnum));
+        assert(!(m[2] & F::graph));
+
+        // '.'
+        assert(!(m[3] & F::space));
+        assert( (m[3] & F::print));
+        assert(!(m[3] & F::cntrl));
+        assert(!(m[3] & F::upper));
+        assert(!(m[3] & F::lower));
+        assert(!(m[3] & F::alpha));
+        assert(!(m[3] & F::digit));
+        assert( (m[3] & F::punct));
+        assert(!(m[3] & F::xdigit));
+        assert(!(m[3] & F::blank));
+        assert(!(m[3] & F::alnum));
+        assert( (m[3] & F::graph));
+
+        // 'a'
+        assert(!(m[4] & F::space));
+        assert( (m[4] & F::print));
+        assert(!(m[4] & F::cntrl));
+        assert(!(m[4] & F::upper));
+        assert( (m[4] & F::lower));
+        assert( (m[4] & F::alpha));
+        assert(!(m[4] & F::digit));
+        assert(!(m[4] & F::punct));
+        assert( (m[4] & F::xdigit));
+        assert(!(m[4] & F::blank));
+        assert( (m[4] & F::alnum));
+        assert( (m[4] & F::graph));
+
+        // '1'
+        assert(!(m[5] & F::space));
+        assert( (m[5] & F::print));
+        assert(!(m[5] & F::cntrl));
+        assert(!(m[5] & F::upper));
+        assert(!(m[5] & F::lower));
+        assert(!(m[5] & F::alpha));
+        assert( (m[5] & F::digit));
+        assert(!(m[5] & F::punct));
+        assert( (m[5] & F::xdigit));
+        assert(!(m[5] & F::blank));
+        assert( (m[5] & F::alnum));
+        assert( (m[5] & F::graph));
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
new file mode 100644
index 0000000..45ca8a4
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char narrow(char c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.narrow(' ', '*') == ' ');
+        assert(f.narrow('A', '*') == 'A');
+        assert(f.narrow('\x07', '*') == '\x07');
+        assert(f.narrow('.', '*') == '.');
+        assert(f.narrow('a', '*') == 'a');
+        assert(f.narrow('1', '*') == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
new file mode 100644
index 0000000..d4816c4
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* narrow(const char* low, const char*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
new file mode 100644
index 0000000..1e2db54
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_is(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+        assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+        assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+        assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
new file mode 100644
index 0000000..4859c04
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_not(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
new file mode 100644
index 0000000..1b9d77e
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// const mask* table() const throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    typedef std::ctype<char> F;
+    {
+        std::locale l(std::locale::classic(), new std::ctype<char>);
+        const F& f = std::use_facet<F>(l);
+        assert(f.table() == f.classic_table());
+    }
+    {
+        std::ctype<char>::mask table[256];
+        std::locale l(std::locale::classic(), new std::ctype<char>(table));
+        const F& f = std::use_facet<F>(l);
+        assert(f.table() == table);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
new file mode 100644
index 0000000..8e3f397
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char tolower(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.tolower(' ') == ' ');
+        assert(f.tolower('A') == 'a');
+        assert(f.tolower('\x07') == '\x07');
+        assert(f.tolower('.') == '.');
+        assert(f.tolower('a') == 'a');
+        assert(f.tolower('1') == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp
new file mode 100644
index 0000000..2263c00
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* tolower(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+
+        assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == ' ');
+        assert(in[1] == 'a');
+        assert(in[2] == '\x07');
+        assert(in[3] == '.');
+        assert(in[4] == 'a');
+        assert(in[5] == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
new file mode 100644
index 0000000..ce0e4a1
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char toupper(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.toupper(' ') == ' ');
+        assert(f.toupper('A') == 'A');
+        assert(f.toupper('\x07') == '\x07');
+        assert(f.toupper('.') == '.');
+        assert(f.toupper('a') == 'A');
+        assert(f.toupper('1') == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp
new file mode 100644
index 0000000..5e5e684
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* toupper(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+
+        assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == ' ');
+        assert(in[1] == 'A');
+        assert(in[2] == '\x07');
+        assert(in[3] == '.');
+        assert(in[4] == 'A');
+        assert(in[5] == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
new file mode 100644
index 0000000..d5dde81
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.widen(' ') == ' ');
+        assert(f.widen('A') == 'A');
+        assert(f.widen('\x07') == '\x07');
+        assert(f.widen('.') == '.');
+        assert(f.widen('a') == 'a');
+        assert(f.widen('1') == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
new file mode 100644
index 0000000..24ac66e
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* widen(const char* low, const char* high, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
new file mode 100644
index 0000000..aa3a9dd
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// static const mask* classic_table() throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    typedef std::ctype<char> F;
+    assert(F::classic_table() != 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp b/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
new file mode 100644
index 0000000..1f01852
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> 
+// class ctype<char>
+//     : public locale::facet,
+//       public ctype_base
+// {
+// public: 
+//     typedef char char_type; 
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::ctype<char> >(l));
+        const std::ctype<char>& f = std::use_facet<std::ctype<char> >(l);
+        {
+            (void)std::ctype<char>::id;
+        }
+        static_assert((std::is_same<std::ctype<char>::char_type, char>::value), "");
+        static_assert((std::is_base_of<std::ctype_base, std::ctype<char> >::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::ctype<char> >::value), "");
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
new file mode 100644
index 0000000..2ae467a
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
new file mode 100644
index 0000000..f5c1a6d
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char16_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
new file mode 100644
index 0000000..f38ea15
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char32_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
new file mode 100644
index 0000000..ccc183f
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<wchar_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
new file mode 100644
index 0000000..60ca4fd
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class codecvt_base
+// {
+// public: 
+//     enum result {ok, partial, error, noconv};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    assert(std::codecvt_base::ok == 0);
+    assert(std::codecvt_base::partial == 1);
+    assert(std::codecvt_base::error == 2);
+    assert(std::codecvt_base::noconv == 3);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
new file mode 100644
index 0000000..69b76b2
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
new file mode 100644
index 0000000..79d6cd2
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+//#endif
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
new file mode 100644
index 0000000..41a7dfb
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+//#endif
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
new file mode 100644
index 0000000..096b1b9
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..43d21df
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp
new file mode 100644
index 0000000..3249404
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
new file mode 100644
index 0000000..71800ff
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result in(stateT& state, 
+//           const externT* from, const externT* from_end, const externT*& from_next, 
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const char from[] = "some text";
+    F::intern_type to[9];
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char* from_next = 0;
+    F::intern_type* to_next = 0;
+    assert(f.in(mbs, from, from + 9, from_next,
+                     to, to + 9, to_next) == F::ok);
+    assert(from_next - from == 9);
+    assert(to_next - to == 9);
+    for (unsigned i = 0; i < 9; ++i)
+        assert(to[i] == from[i]);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
new file mode 100644
index 0000000..b642160
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char from[] = "some text";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 8) == 8);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp
new file mode 100644
index 0000000..e4346b1
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 4);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp
new file mode 100644
index 0000000..978075f
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result out(stateT& state, 
+//            const internT* from, const internT* from_end, const internT*& from_next, 
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+        char to[9] = {0};
+        std::mbstate_t mbs;
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from, from + 9, from_next,
+                                 to, to + 9, to_next);
+        assert(r == F::ok);
+        assert(from_next - from == 9);
+        assert(to_next - to == 9);
+        for (unsigned i = 0; i < 9; ++i)
+            assert(to[i] == from[i]);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
new file mode 100644
index 0000000..484c29b
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..93ee795
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp
new file mode 100644
index 0000000..fa982c9
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
new file mode 100644
index 0000000..56dcd0c
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result in(stateT& state, 
+//           const externT* from, const externT* from_end, const externT*& from_next, 
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const char from[] = "some text";
+    F::intern_type to[9];
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char* from_next = 0;
+    F::intern_type* to_next = 0;
+    assert(f.in(mbs, from, from + 9, from_next,
+                     to, to + 9, to_next) == F::ok);
+    assert(from_next - from == 9);
+    assert(to_next - to == 9);
+    for (unsigned i = 0; i < 9; ++i)
+        assert(to[i] == from[i]);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp
new file mode 100644
index 0000000..aa59da9
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char from[] = "some text";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 8) == 8);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp
new file mode 100644
index 0000000..ff5869b
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 4);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp
new file mode 100644
index 0000000..0f6288e
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result out(stateT& state, 
+//            const internT* from, const internT* from_end, const internT*& from_next, 
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+        char to[9] = {0};
+        std::mbstate_t mbs;
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from, from + 9, from_next,
+                                 to, to + 9, to_next);
+        assert(r == F::ok);
+        assert(from_next - from == 9);
+        assert(to_next - to == 9);
+        for (unsigned i = 0; i < 9; ++i)
+            assert(to[i] == from[i]);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
new file mode 100644
index 0000000..80e3485
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp
new file mode 100644
index 0000000..d98d8d4
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.always_noconv());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp
new file mode 100644
index 0000000..32ef730
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 1);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
new file mode 100644
index 0000000..ddcc640
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result in(stateT& state, 
+//           const externT* from, const externT* from_end, const externT*& from_next, 
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::intern_type> from("some text");
+    std::vector<char> to(from.size());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char* from_next = 0;
+    char* to_next = 0;
+    assert(f.in(mbs, from.data(), from.data() + from.size(), from_next,
+                     to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(from_next == from.data());
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp
new file mode 100644
index 0000000..1e4df5c
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char from[10]= {0};
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 11) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp
new file mode 100644
index 0000000..0237953
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 1);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
new file mode 100644
index 0000000..6e91415
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result out(stateT& state, 
+//            const internT* from, const internT* from_end, const internT*& from_next, 
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::intern_type> from("some text");
+    std::vector<char> to(from.size());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    const char* from_next = 0;
+    char* to_next = 0;
+    assert(f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                      to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(from_next == from.data());
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
new file mode 100644
index 0000000..4f62d9a
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs;
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
new file mode 100644
index 0000000..4de21f5
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+// template <> class codecvt<char16_t, char, mbstate_t>
+// template <> class codecvt<char32_t, char16_t, mbstate_t>  // extension
+
+// sanity check
+
+#include <locale>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    typedef std::codecvt<char32_t, char, std::mbstate_t> F32_8;
+    typedef std::codecvt<char16_t, char, std::mbstate_t> F16_8;
+    typedef std::codecvt<char32_t, char16_t, std::mbstate_t> F32_16;
+    std::locale l = std::locale(std::locale::classic(), new F32_16);
+    const F32_8& f32_8 = std::use_facet<F32_8>(l);
+    const F32_16& f32_16 = std::use_facet<F32_16>(l);
+    const F16_8& f16_8 = std::use_facet<F16_8>(l);
+    std::mbstate_t mbs = {0};
+    F32_8::intern_type* c32p;
+    F16_8::intern_type* c16p;
+    F32_8::extern_type* c8p;
+    const F32_8::intern_type* c_c32p;
+    const F16_8::intern_type* c_c16p;
+    const F32_8::extern_type* c_c8p;
+    F32_8::intern_type c32;
+    F16_8::intern_type c16[2];
+    F32_8::extern_type c8[4];
+    for (F32_8::intern_type c32x = 0; c32x < 0x110003; ++c32x)
+    {
+        if (0xD800 <= c32x && c32x < 0xE000 || c32x >= 0x110000)
+        {
+            assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16+0, c16+2, c16p) == F32_8::error);
+            assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::error);
+        }
+        else
+        {
+            assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16, c16+2, c16p) == F32_8::ok);
+            assert(c_c32p-&c32x == 1);
+            if (c32x < 0x10000)
+                assert(c16p-c16 == 1);
+            else
+                assert(c16p-c16 == 2);
+            c_c16p = c16p;
+            assert(f16_8.out(mbs, c16, c_c16p, c_c16p, c8, c8+4, c8p) == F32_8::ok);
+            if (c32x < 0x10000)
+                assert(c_c16p-c16 == 1);
+            else
+                assert(c_c16p-c16 == 2);
+            if (c32x < 0x80)
+                assert(c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c8p-c8 == 3);
+            else
+                assert(c8p-c8 == 4);
+            c_c8p = c8p;
+            assert(f32_8.in(mbs, c8, c_c8p, c_c8p, &c32, &c32+1, c32p) == F32_8::ok);
+            if (c32x < 0x80)
+                assert(c_c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c_c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c_c8p-c8 == 3);
+            else
+                assert(c_c8p-c8 == 4);
+            assert(c32p-&c32 == 1);
+            assert(c32 == c32x);
+            assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::ok);
+            assert(c_c32p-&c32x == 1);
+            if (c32x < 0x80)
+                assert(c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c8p-c8 == 3);
+            else
+                assert(c8p-c8 == 4);
+            c_c8p = c8p;
+            assert(f16_8.in(mbs, c8, c_c8p, c_c8p, c16, c16+2, c16p) == F32_8::ok);
+            if (c32x < 0x80)
+                assert(c_c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c_c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c_c8p-c8 == 3);
+            else
+                assert(c_c8p-c8 == 4);
+            if (c32x < 0x10000)
+                assert(c16p-c16 == 1);
+            else
+                assert(c16p-c16 == 2);
+            c_c16p = c16p;
+            assert(f32_16.in(mbs, c16, c_c16p, c_c16p, &c32, &c32+1, c32p) == F32_8::ok);
+            if (c32x < 0x10000)
+                assert(c_c16p-c16 == 1);
+            else
+                assert(c_c16p-c16 == 2);
+            assert(c32p-&c32 == 1);
+            assert(c32 == c32x);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..9953d95
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp
new file mode 100644
index 0000000..502d676
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 1);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
new file mode 100644
index 0000000..39ed2b1
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result in(stateT& state, 
+//           const externT* from, const externT* from_end, const externT*& from_next, 
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::extern_type> from("some text");
+    const std::basic_string<F::intern_type> expected(from.begin(), from.end());
+    std::basic_string<F::intern_type> to(from.size(), F::intern_type());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const F::extern_type* from_next = 0;
+    F::intern_type* to_next = 0;
+    F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next,
+                            &to[0], &to[0] + to.size(), to_next);
+    assert(r == F::ok);
+    assert(from_next - from.data() == from.size());
+    assert(to_next - to.data() == expected.size());
+    assert(to_next - to.data() == expected.size());
+    assert(to == expected);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp
new file mode 100644
index 0000000..0c19222
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from = "123467890";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 11) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp
new file mode 100644
index 0000000..70f349f
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 1);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp
new file mode 100644
index 0000000..b90b357
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result out(stateT& state, 
+//            const internT* from, const internT* from_end, const internT*& from_next, 
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        const std::basic_string<F::intern_type> from(L"some text");
+        std::vector<char> to(from.size()+1);
+        std::mbstate_t mbs;
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size(), to_next);
+        assert(r == F::ok);
+        assert(from_next - from.data() == from.size());
+        assert(to_next - to.data() == from.size());
+        assert(to.data() == std::string("some text"));
+    }
+    {
+        std::basic_string<F::intern_type> from(L"some text");
+        from[4] = '\0';
+        std::vector<char> to(from.size()+1);
+        std::mbstate_t mbs;
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size(), to_next);
+        assert(r == F::ok);
+        assert(from_next - from.data() == from.size());
+        assert(to_next - to.data() == from.size());
+        assert(to.data() == std::string("some\0text", from.size()));
+    }
+    {
+        std::basic_string<F::intern_type> from(L"some text");
+        std::vector<char> to(from.size()-1);
+        std::mbstate_t mbs;
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size()-1, to_next);
+        assert(r == F::partial);
+        assert(from_next - from.data() == to.size()-1);
+        assert(to_next - to.data() == to.size()-1);
+        assert(to.data() == std::string("some te"));
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
new file mode 100644
index 0000000..f5bde98
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+// This is pretty much just an "are you breathing" test
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<F::extern_type> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    F::extern_type* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::ok);
+    assert(to_next == to.data());
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
new file mode 100644
index 0000000..8d56421
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public: 
+//     typedef char      intern_type; 
+//     typedef char      extern_type; 
+//     typedef mbstate_t state_type; 
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt<char, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
new file mode 100644
index 0000000..ef6eb49
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char16_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public: 
+//     typedef char16_t  intern_type; 
+//     typedef char      extern_type; 
+//     typedef mbstate_t state_type; 
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char16_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+//#endif
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
new file mode 100644
index 0000000..b626ca6
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char32_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public: 
+//     typedef char32_t  intern_type; 
+//     typedef char      extern_type; 
+//     typedef mbstate_t state_type; 
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char32_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+//#endif
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp b/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
new file mode 100644
index 0000000..8a70fea
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<wchar_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public: 
+//     typedef wchar_t   intern_type; 
+//     typedef char      extern_type; 
+//     typedef mbstate_t state_type; 
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, wchar_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
new file mode 100644
index 0000000..7d97a57
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.is(F::space, L' '));
+            assert(!f.is(F::space, L'A'));
+    
+            assert(f.is(F::print, L' '));
+            assert(!f.is(F::print, L'\x07'));
+    
+            assert(f.is(F::cntrl, L'\x07'));
+            assert(!f.is(F::cntrl, L' '));
+    
+            assert(f.is(F::upper, L'A'));
+            assert(!f.is(F::upper, L'a'));
+    
+            assert(f.is(F::lower, L'a'));
+            assert(!f.is(F::lower, L'A'));
+    
+            assert(f.is(F::alpha, L'a'));
+            assert(!f.is(F::alpha, L'1'));
+    
+            assert(f.is(F::digit, L'1'));
+            assert(!f.is(F::digit, L'a'));
+    
+            assert(f.is(F::punct, L'.'));
+            assert(!f.is(F::punct, L'a'));
+    
+            assert(f.is(F::xdigit, L'a'));
+            assert(!f.is(F::xdigit, L'g'));
+    
+            assert(f.is(F::alnum, L'a'));
+            assert(!f.is(F::alnum, L'.'));
+    
+            assert(f.is(F::graph, L'.'));
+            assert(!f.is(F::graph,  L'\x07'));
+
+            assert(f.is(F::alpha, L'\x00DA'));
+            assert(f.is(F::upper, L'\x00DA'));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.is(F::space, L' '));
+            assert(!f.is(F::space, L'A'));
+    
+            assert(f.is(F::print, L' '));
+            assert(!f.is(F::print, L'\x07'));
+    
+            assert(f.is(F::cntrl, L'\x07'));
+            assert(!f.is(F::cntrl, L' '));
+    
+            assert(f.is(F::upper, L'A'));
+            assert(!f.is(F::upper, L'a'));
+    
+            assert(f.is(F::lower, L'a'));
+            assert(!f.is(F::lower, L'A'));
+    
+            assert(f.is(F::alpha, L'a'));
+            assert(!f.is(F::alpha, L'1'));
+    
+            assert(f.is(F::digit, L'1'));
+            assert(!f.is(F::digit, L'a'));
+    
+            assert(f.is(F::punct, L'.'));
+            assert(!f.is(F::punct, L'a'));
+    
+            assert(f.is(F::xdigit, L'a'));
+            assert(!f.is(F::xdigit, L'g'));
+    
+            assert(f.is(F::alnum, L'a'));
+            assert(!f.is(F::alnum, L'.'));
+    
+            assert(f.is(F::graph, L'.'));
+            assert(!f.is(F::graph,  L'\x07'));
+
+            assert(!f.is(F::alpha, L'\x00DA'));
+            assert(!f.is(F::upper, L'\x00DA'));
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
new file mode 100644
index 0000000..5f0f7b6
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
@@ -0,0 +1,243 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+            assert(h == in.data() + in.size());
+    
+            // L'\x00DA'
+            assert(!(m[0] & F::space));
+            assert( (m[0] & F::print));
+            assert(!(m[0] & F::cntrl));
+            assert( (m[0] & F::upper));
+            assert(!(m[0] & F::lower));
+            assert( (m[0] & F::alpha));
+            assert(!(m[0] & F::digit));
+            assert(!(m[0] & F::punct));
+            assert(!(m[0] & F::xdigit));
+            assert(!(m[0] & F::blank));
+            assert( (m[0] & F::alnum));
+            assert( (m[0] & F::graph));
+    
+            // L' '
+            assert( (m[1] & F::space));
+            assert( (m[1] & F::print));
+            assert(!(m[1] & F::cntrl));
+            assert(!(m[1] & F::upper));
+            assert(!(m[1] & F::lower));
+            assert(!(m[1] & F::alpha));
+            assert(!(m[1] & F::digit));
+            assert(!(m[1] & F::punct));
+            assert(!(m[1] & F::xdigit));
+            assert( (m[1] & F::blank));
+            assert(!(m[1] & F::alnum));
+            assert(!(m[1] & F::graph));
+    
+            // L'A'
+            assert(!(m[2] & F::space));
+            assert( (m[2] & F::print));
+            assert(!(m[2] & F::cntrl));
+            assert( (m[2] & F::upper));
+            assert(!(m[2] & F::lower));
+            assert( (m[2] & F::alpha));
+            assert(!(m[2] & F::digit));
+            assert(!(m[2] & F::punct));
+            assert( (m[2] & F::xdigit));
+            assert(!(m[2] & F::blank));
+            assert( (m[2] & F::alnum));
+            assert( (m[2] & F::graph));
+    
+            // L'\x07'
+            assert(!(m[3] & F::space));
+            assert(!(m[3] & F::print));
+            assert( (m[3] & F::cntrl));
+            assert(!(m[3] & F::upper));
+            assert(!(m[3] & F::lower));
+            assert(!(m[3] & F::alpha));
+            assert(!(m[3] & F::digit));
+            assert(!(m[3] & F::punct));
+            assert(!(m[3] & F::xdigit));
+            assert(!(m[3] & F::blank));
+            assert(!(m[3] & F::alnum));
+            assert(!(m[3] & F::graph));
+    
+            // L'.'
+            assert(!(m[4] & F::space));
+            assert( (m[4] & F::print));
+            assert(!(m[4] & F::cntrl));
+            assert(!(m[4] & F::upper));
+            assert(!(m[4] & F::lower));
+            assert(!(m[4] & F::alpha));
+            assert(!(m[4] & F::digit));
+            assert( (m[4] & F::punct));
+            assert(!(m[4] & F::xdigit));
+            assert(!(m[4] & F::blank));
+            assert(!(m[4] & F::alnum));
+            assert( (m[4] & F::graph));
+    
+            // L'a'
+            assert(!(m[5] & F::space));
+            assert( (m[5] & F::print));
+            assert(!(m[5] & F::cntrl));
+            assert(!(m[5] & F::upper));
+            assert( (m[5] & F::lower));
+            assert( (m[5] & F::alpha));
+            assert(!(m[5] & F::digit));
+            assert(!(m[5] & F::punct));
+            assert( (m[5] & F::xdigit));
+            assert(!(m[5] & F::blank));
+            assert( (m[5] & F::alnum));
+            assert( (m[5] & F::graph));
+    
+            // L'1'
+            assert(!(m[6] & F::space));
+            assert( (m[6] & F::print));
+            assert(!(m[6] & F::cntrl));
+            assert(!(m[6] & F::upper));
+            assert(!(m[6] & F::lower));
+            assert(!(m[6] & F::alpha));
+            assert( (m[6] & F::digit));
+            assert(!(m[6] & F::punct));
+            assert( (m[6] & F::xdigit));
+            assert(!(m[6] & F::blank));
+            assert( (m[6] & F::alnum));
+            assert( (m[6] & F::graph));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+            assert(h == in.data() + in.size());
+    
+            // L'\x00DA'
+            assert(!(m[0] & F::space));
+            assert(!(m[0] & F::print));
+            assert(!(m[0] & F::cntrl));
+            assert(!(m[0] & F::upper));
+            assert(!(m[0] & F::lower));
+            assert(!(m[0] & F::alpha));
+            assert(!(m[0] & F::digit));
+            assert(!(m[0] & F::punct));
+            assert(!(m[0] & F::xdigit));
+            assert(!(m[0] & F::blank));
+            assert(!(m[0] & F::alnum));
+            assert(!(m[0] & F::graph));
+    
+            // L' '
+            assert( (m[1] & F::space));
+            assert( (m[1] & F::print));
+            assert(!(m[1] & F::cntrl));
+            assert(!(m[1] & F::upper));
+            assert(!(m[1] & F::lower));
+            assert(!(m[1] & F::alpha));
+            assert(!(m[1] & F::digit));
+            assert(!(m[1] & F::punct));
+            assert(!(m[1] & F::xdigit));
+            assert( (m[1] & F::blank));
+            assert(!(m[1] & F::alnum));
+            assert(!(m[1] & F::graph));
+    
+            // L'A'
+            assert(!(m[2] & F::space));
+            assert( (m[2] & F::print));
+            assert(!(m[2] & F::cntrl));
+            assert( (m[2] & F::upper));
+            assert(!(m[2] & F::lower));
+            assert( (m[2] & F::alpha));
+            assert(!(m[2] & F::digit));
+            assert(!(m[2] & F::punct));
+            assert( (m[2] & F::xdigit));
+            assert(!(m[2] & F::blank));
+            assert( (m[2] & F::alnum));
+            assert( (m[2] & F::graph));
+    
+            // L'\x07'
+            assert(!(m[3] & F::space));
+            assert(!(m[3] & F::print));
+            assert( (m[3] & F::cntrl));
+            assert(!(m[3] & F::upper));
+            assert(!(m[3] & F::lower));
+            assert(!(m[3] & F::alpha));
+            assert(!(m[3] & F::digit));
+            assert(!(m[3] & F::punct));
+            assert(!(m[3] & F::xdigit));
+            assert(!(m[3] & F::blank));
+            assert(!(m[3] & F::alnum));
+            assert(!(m[3] & F::graph));
+    
+            // L'.'
+            assert(!(m[4] & F::space));
+            assert( (m[4] & F::print));
+            assert(!(m[4] & F::cntrl));
+            assert(!(m[4] & F::upper));
+            assert(!(m[4] & F::lower));
+            assert(!(m[4] & F::alpha));
+            assert(!(m[4] & F::digit));
+            assert( (m[4] & F::punct));
+            assert(!(m[4] & F::xdigit));
+            assert(!(m[4] & F::blank));
+            assert(!(m[4] & F::alnum));
+            assert( (m[4] & F::graph));
+    
+            // L'a'
+            assert(!(m[5] & F::space));
+            assert( (m[5] & F::print));
+            assert(!(m[5] & F::cntrl));
+            assert(!(m[5] & F::upper));
+            assert( (m[5] & F::lower));
+            assert( (m[5] & F::alpha));
+            assert(!(m[5] & F::digit));
+            assert(!(m[5] & F::punct));
+            assert( (m[5] & F::xdigit));
+            assert(!(m[5] & F::blank));
+            assert( (m[5] & F::alnum));
+            assert( (m[5] & F::graph));
+    
+            // L'1'
+            assert(!(m[6] & F::space));
+            assert( (m[6] & F::print));
+            assert(!(m[6] & F::cntrl));
+            assert(!(m[6] & F::upper));
+            assert(!(m[6] & F::lower));
+            assert(!(m[6] & F::alpha));
+            assert( (m[6] & F::digit));
+            assert(!(m[6] & F::punct));
+            assert( (m[6] & F::xdigit));
+            assert(!(m[6] & F::blank));
+            assert( (m[6] & F::alnum));
+            assert( (m[6] & F::graph));
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
new file mode 100644
index 0000000..048c280
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l(std::string("fr_CA.ISO8859-1"));
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.narrow(L' ', '*') == ' ');
+            assert(f.narrow(L'A', '*') == 'A');
+            assert(f.narrow(L'\x07', '*') == '\x07');
+            assert(f.narrow(L'.', '*') == '.');
+            assert(f.narrow(L'a', '*') == 'a');
+            assert(f.narrow(L'1', '*') == '1');
+            assert(f.narrow(L'\xDA', '*') == '\xDA');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.narrow(L' ', '*') == ' ');
+            assert(f.narrow(L'A', '*') == 'A');
+            assert(f.narrow(L'\x07', '*') == '\x07');
+            assert(f.narrow(L'.', '*') == '.');
+            assert(f.narrow(L'a', '*') == 'a');
+            assert(f.narrow(L'1', '*') == '1');
+            assert(f.narrow(L'\xDA', '*') == '*');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
new file mode 100644
index 0000000..03353ff
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("fr_CA.ISO8859-1");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L" A\x07.a1\xDA");
+            std::vector<char> v(in.size());
+    
+            assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+            assert(v[0] == ' ');
+            assert(v[1] == 'A');
+            assert(v[2] == '\x07');
+            assert(v[3] == '.');
+            assert(v[4] == 'a');
+            assert(v[5] == '1');
+            assert(v[6] == '\xDA');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L" A\x07.a1\xDA");
+            std::vector<char> v(in.size());
+    
+            assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+            assert(v[0] == ' ');
+            assert(v[1] == 'A');
+            assert(v[2] == '\x07');
+            assert(v[3] == '.');
+            assert(v[4] == 'a');
+            assert(v[5] == '1');
+            assert(v[6] == '*');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
new file mode 100644
index 0000000..11a80cd
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+            assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+            assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+            assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+            assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+            assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+            assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 2);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
new file mode 100644
index 0000000..b7e8440
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
new file mode 100644
index 0000000..7e890ff
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT tolower(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.tolower(' ') == ' ');
+            assert(f.tolower('A') == 'a');
+            assert(f.tolower('\x07') == '\x07');
+            assert(f.tolower('.') == '.');
+            assert(f.tolower('a') == 'a');
+            assert(f.tolower('1') == '1');
+            assert(f.tolower('\xDA') == '\xDA');
+            assert(f.tolower('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.tolower(' ') == ' ');
+            assert(f.tolower('A') == 'a');
+            assert(f.tolower('\x07') == '\x07');
+            assert(f.tolower('.') == '.');
+            assert(f.tolower('a') == 'a');
+            assert(f.tolower('1') == '1');
+            assert(f.tolower('\xDA') == '\xDA');
+            assert(f.tolower('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.tolower(L' ') == L' ');
+            assert(f.tolower(L'A') == L'a');
+            assert(f.tolower(L'\x07') == L'\x07');
+            assert(f.tolower(L'.') == L'.');
+            assert(f.tolower(L'a') == L'a');
+            assert(f.tolower(L'1') == L'1');
+            assert(f.tolower(L'\xDA') == L'\xFA');
+            assert(f.tolower(L'\xFA') == L'\xFA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.tolower(L' ') == L' ');
+            assert(f.tolower(L'A') == L'a');
+            assert(f.tolower(L'\x07') == L'\x07');
+            assert(f.tolower(L'.') == L'.');
+            assert(f.tolower(L'a') == L'a');
+            assert(f.tolower(L'1') == L'1');
+            assert(f.tolower(L'\xDA') == L'\xDA');
+            assert(f.tolower(L'\xFA') == L'\xFA');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
new file mode 100644
index 0000000..940fe4c
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xDA A\x07.a1");
+    
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xDA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'a');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'a');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xDA A\x07.a1");
+    
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xDA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'a');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'a');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xDA A\x07.a1");
+    
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xFA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'a');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'a');
+            assert(in[6] == L'1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xDA A\x07.a1");
+    
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xDA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'a');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'a');
+            assert(in[6] == L'1');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
new file mode 100644
index 0000000..42fba69
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT toupper(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.toupper(' ') == ' ');
+            assert(f.toupper('A') == 'A');
+            assert(f.toupper('\x07') == '\x07');
+            assert(f.toupper('.') == '.');
+            assert(f.toupper('a') == 'A');
+            assert(f.toupper('1') == '1');
+            assert(f.toupper('\xDA') == '\xDA');
+            assert(f.toupper('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.toupper(' ') == ' ');
+            assert(f.toupper('A') == 'A');
+            assert(f.toupper('\x07') == '\x07');
+            assert(f.toupper('.') == '.');
+            assert(f.toupper('a') == 'A');
+            assert(f.toupper('1') == '1');
+            assert(f.toupper('\xDA') == '\xDA');
+            assert(f.toupper('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.toupper(L' ') == L' ');
+            assert(f.toupper(L'A') == L'A');
+            assert(f.toupper(L'\x07') == L'\x07');
+            assert(f.toupper(L'.') == L'.');
+            assert(f.toupper(L'a') == L'A');
+            assert(f.toupper(L'1') == L'1');
+            assert(f.toupper(L'\xDA') == L'\xDA');
+            assert(f.toupper(L'\xFA') == L'\xDA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.toupper(L' ') == L' ');
+            assert(f.toupper(L'A') == L'A');
+            assert(f.toupper(L'\x07') == L'\x07');
+            assert(f.toupper(L'.') == L'.');
+            assert(f.toupper(L'a') == L'A');
+            assert(f.toupper(L'1') == L'1');
+            assert(f.toupper(L'\xDA') == L'\xDA');
+            assert(f.toupper(L'\xFA') == L'\xFA');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
new file mode 100644
index 0000000..b782c04
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xFA A\x07.a1");
+    
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xFA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'A');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'A');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xFA A\x07.a1");
+    
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xFA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'A');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'A');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xFA A\x07.a1");
+    
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xDA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'A');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'A');
+            assert(in[6] == L'1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xFA A\x07.a1");
+    
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xFA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'A');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'A');
+            assert(in[6] == L'1');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp
new file mode 100644
index 0000000..15fa797
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT>
+// class ctype_byname
+//     : public ctype<CharT>
+// {
+// public: 
+//     explicit ctype_byname(const char*, size_t = 0); 
+//     explicit ctype_byname(const string&, size_t = 0); 
+// 
+// protected: 
+//     ~ctype_byname(); 
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+    {
+        std::locale l("");
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
new file mode 100644
index 0000000..1417d03
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT widen(char c) const;
+
+// I doubt this test is portable
+
+#include <locale>
+#include <cassert>
+#include <limits.h>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.widen(' ') == L' ');
+            assert(f.widen('A') == L'A');
+            assert(f.widen('\x07') == L'\x07');
+            assert(f.widen('.') == L'.');
+            assert(f.widen('a') == L'a');
+            assert(f.widen('1') == L'1');
+            assert(f.widen(char(-5)) == wchar_t(-1));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+    
+            assert(f.widen(' ') == L' ');
+            assert(f.widen('A') == L'A');
+            assert(f.widen('\x07') == L'\x07');
+            assert(f.widen('.') == L'.');
+            assert(f.widen('a') == L'a');
+            assert(f.widen('1') == L'1');
+            assert(f.widen(char(-5)) == wchar_t(251));
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
new file mode 100644
index 0000000..1d5312f
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+// I doubt this test is portable
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("en_US");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in(" A\x07.a1\x85");
+            std::vector<wchar_t> v(in.size());
+    
+            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+            assert(v[0] == L' ');
+            assert(v[1] == L'A');
+            assert(v[2] == L'\x07');
+            assert(v[3] == L'.');
+            assert(v[4] == L'a');
+            assert(v[5] == L'1');
+            assert(v[6] == wchar_t(-1));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in(" A\x07.a1\x85");
+            std::vector<wchar_t> v(in.size());
+    
+            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+            assert(v[0] == L' ');
+            assert(v[1] == L'A');
+            assert(v[2] == L'\x07');
+            assert(v[3] == L'.');
+            assert(v[4] == L'a');
+            assert(v[5] == L'1');
+            assert(v[6] == wchar_t(133));
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
new file mode 100644
index 0000000..935025f
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::ctype<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::ctype<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
new file mode 100644
index 0000000..07c9e87
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.is(F::space, L' '));
+        assert(!f.is(F::space, L'A'));
+
+        assert(f.is(F::print, L' '));
+        assert(!f.is(F::print, L'\x07'));
+
+        assert(f.is(F::cntrl, L'\x07'));
+        assert(!f.is(F::cntrl, L' '));
+
+        assert(f.is(F::upper, L'A'));
+        assert(!f.is(F::upper, L'a'));
+
+        assert(f.is(F::lower, L'a'));
+        assert(!f.is(F::lower, L'A'));
+
+        assert(f.is(F::alpha, L'a'));
+        assert(!f.is(F::alpha, L'1'));
+
+        assert(f.is(F::digit, L'1'));
+        assert(!f.is(F::digit, L'a'));
+
+        assert(f.is(F::punct, L'.'));
+        assert(!f.is(F::punct, L'a'));
+
+        assert(f.is(F::xdigit, L'a'));
+        assert(!f.is(F::xdigit, L'g'));
+
+        assert(f.is(F::alnum, L'a'));
+        assert(!f.is(F::alnum, L'.'));
+
+        assert(f.is(F::graph, L'.'));
+        assert(!f.is(F::graph,  L'\x07'));
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
new file mode 100644
index 0000000..f1ff948
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+        assert(h == in.data() + in.size());
+
+        // L' '
+        assert( (m[0] & F::space));
+        assert( (m[0] & F::print));
+        assert(!(m[0] & F::cntrl));
+        assert(!(m[0] & F::upper));
+        assert(!(m[0] & F::lower));
+        assert(!(m[0] & F::alpha));
+        assert(!(m[0] & F::digit));
+        assert(!(m[0] & F::punct));
+        assert(!(m[0] & F::xdigit));
+        assert( (m[0] & F::blank));
+        assert(!(m[0] & F::alnum));
+        assert(!(m[0] & F::graph));
+
+        // L'A'
+        assert(!(m[1] & F::space));
+        assert( (m[1] & F::print));
+        assert(!(m[1] & F::cntrl));
+        assert( (m[1] & F::upper));
+        assert(!(m[1] & F::lower));
+        assert( (m[1] & F::alpha));
+        assert(!(m[1] & F::digit));
+        assert(!(m[1] & F::punct));
+        assert( (m[1] & F::xdigit));
+        assert(!(m[1] & F::blank));
+        assert( (m[1] & F::alnum));
+        assert( (m[1] & F::graph));
+
+        // L'\x07'
+        assert(!(m[2] & F::space));
+        assert(!(m[2] & F::print));
+        assert( (m[2] & F::cntrl));
+        assert(!(m[2] & F::upper));
+        assert(!(m[2] & F::lower));
+        assert(!(m[2] & F::alpha));
+        assert(!(m[2] & F::digit));
+        assert(!(m[2] & F::punct));
+        assert(!(m[2] & F::xdigit));
+        assert(!(m[2] & F::blank));
+        assert(!(m[2] & F::alnum));
+        assert(!(m[2] & F::graph));
+
+        // L'.'
+        assert(!(m[3] & F::space));
+        assert( (m[3] & F::print));
+        assert(!(m[3] & F::cntrl));
+        assert(!(m[3] & F::upper));
+        assert(!(m[3] & F::lower));
+        assert(!(m[3] & F::alpha));
+        assert(!(m[3] & F::digit));
+        assert( (m[3] & F::punct));
+        assert(!(m[3] & F::xdigit));
+        assert(!(m[3] & F::blank));
+        assert(!(m[3] & F::alnum));
+        assert( (m[3] & F::graph));
+
+        // L'a'
+        assert(!(m[4] & F::space));
+        assert( (m[4] & F::print));
+        assert(!(m[4] & F::cntrl));
+        assert(!(m[4] & F::upper));
+        assert( (m[4] & F::lower));
+        assert( (m[4] & F::alpha));
+        assert(!(m[4] & F::digit));
+        assert(!(m[4] & F::punct));
+        assert( (m[4] & F::xdigit));
+        assert(!(m[4] & F::blank));
+        assert( (m[4] & F::alnum));
+        assert( (m[4] & F::graph));
+
+        // L'1'
+        assert(!(m[5] & F::space));
+        assert( (m[5] & F::print));
+        assert(!(m[5] & F::cntrl));
+        assert(!(m[5] & F::upper));
+        assert(!(m[5] & F::lower));
+        assert(!(m[5] & F::alpha));
+        assert( (m[5] & F::digit));
+        assert(!(m[5] & F::punct));
+        assert( (m[5] & F::xdigit));
+        assert(!(m[5] & F::blank));
+        assert( (m[5] & F::alnum));
+        assert( (m[5] & F::graph));
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
new file mode 100644
index 0000000..ac21d48
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.narrow(L' ', '*') == ' ');
+        assert(f.narrow(L'A', '*') == 'A');
+        assert(f.narrow(L'\x07', '*') == '\x07');
+        assert(f.narrow(L'.', '*') == '.');
+        assert(f.narrow(L'a', '*') == 'a');
+        assert(f.narrow(L'1', '*') == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
new file mode 100644
index 0000000..a9ffcc4
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
new file mode 100644
index 0000000..f90c4ee
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+        assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+        assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+        assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
new file mode 100644
index 0000000..6f5b760
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
new file mode 100644
index 0000000..20d0e77
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT tolower(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.tolower(L' ') == L' ');
+        assert(f.tolower(L'A') == L'a');
+        assert(f.tolower(L'\x07') == L'\x07');
+        assert(f.tolower(L'.') == L'.');
+        assert(f.tolower(L'a') == L'a');
+        assert(f.tolower(L'1') == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp
new file mode 100644
index 0000000..18e8925
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+
+        assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == L' ');
+        assert(in[1] == L'a');
+        assert(in[2] == L'\x07');
+        assert(in[3] == L'.');
+        assert(in[4] == L'a');
+        assert(in[5] == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
new file mode 100644
index 0000000..f755679
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT toupper(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.toupper(L' ') == L' ');
+        assert(f.toupper(L'A') == L'A');
+        assert(f.toupper(L'\x07') == L'\x07');
+        assert(f.toupper(L'.') == L'.');
+        assert(f.toupper(L'a') == L'A');
+        assert(f.toupper(L'1') == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp
new file mode 100644
index 0000000..7bdd7b7
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+
+        assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == L' ');
+        assert(in[1] == L'A');
+        assert(in[2] == L'\x07');
+        assert(in[3] == L'.');
+        assert(in[4] == L'A');
+        assert(in[5] == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
new file mode 100644
index 0000000..296c4e3
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.widen(' ') == L' ');
+        assert(f.widen('A') == L'A');
+        assert(f.widen('\x07') == L'\x07');
+        assert(f.widen('.') == L'.');
+        assert(f.widen('a') == L'a');
+        assert(f.widen('1') == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
new file mode 100644
index 0000000..e222f21
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<wchar_t> v(in.size());
+
+        assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+        assert(v[0] == L' ');
+        assert(v[1] == L'A');
+        assert(v[2] == L'\x07');
+        assert(v[3] == L'.');
+        assert(v[4] == L'a');
+        assert(v[5] == L'1');
+    }
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp b/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
new file mode 100644
index 0000000..67a9c62
--- /dev/null
+++ b/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT> 
+// class ctype
+//     : public locale::facet,
+//       public ctype_base
+// {
+// public: 
+//     typedef CharT char_type; 
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::ctype<wchar_t> >(l));
+        const std::ctype<wchar_t>& f = std::use_facet<std::ctype<wchar_t> >(l);
+        {
+            (void)std::ctype<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::ctype<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_base_of<std::ctype_base, std::ctype<wchar_t> >::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::ctype<wchar_t> >::value), "");
+    }
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
new file mode 100644
index 0000000..fc4d676
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// explicit messages(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::messages<char> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
new file mode 100644
index 0000000..bc91b62
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// catalog open(const basic_string<char>& name, const locale&) const;
+
+#include <locale>
+#include <cassert>
+
+// As far as I can tell, the messages facet is untestable.  I have a best
+// effort implementation in the hopes that in the future I will learn how
+// to test it.
+
+template <class CharT>
+class F
+    : public std::messages<CharT>
+{
+public:
+    explicit F(std::size_t refs = 0)
+        : std::messages<CharT>(refs) {}
+};
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
new file mode 100644
index 0000000..f8acf89
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages_base
+// {
+// public:
+//     typedef unspecified catalog;
+// };
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    std::messages_base mb;
+}
diff --git a/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp b/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
new file mode 100644
index 0000000..5a69681
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class _CharT>
+// class messages
+//     : public locale::facet,
+//       public messages_base
+// {
+// public:
+//     typedef _CharT               char_type;
+//     typedef basic_string<_CharT> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::messages<char> >::value), "");
+    static_assert((std::is_base_of<std::messages_base, std::messages<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::messages<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::messages_base, std::messages<wchar_t> >::value), "");
+    static_assert((std::is_same<std::messages<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::messages<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::messages<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::messages<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
new file mode 100644
index 0000000..abbd8b5
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// explicit money_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_get<char, const char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
new file mode 100644
index 0000000..440c140
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
@@ -0,0 +1,719 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("en_US");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
new file mode 100644
index 0000000..df38b1f
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -0,0 +1,723 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("fr_FR");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "0,01 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "1 234 567,89 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "1234567,89 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 Eu";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 Eu";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "0,01 Eu-";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "0,01 Eu-";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 Eu";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 Eu";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 EUR -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "0,01 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "1 234 567,89 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "1234567,89 -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 EUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 EUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "0,01 EUR -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "0,01 EUR -";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 EUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 EUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 Eu-";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"0,01 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"1 234 567,89 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"1234567,89 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 Eu";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 Eu";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"0,01 Eu-";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"0,01 Eu-";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 Eu";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 Eu";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 EUR -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"0,01 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"1 234 567,89 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"1234567,89 -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 EUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 EUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"0,01 EUR -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"0,01 EUR -";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 EUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 EUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 Eu-";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
new file mode 100644
index 0000000..a20d913
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
@@ -0,0 +1,723 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("ru_RU");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0,00 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 RUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 RUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 RUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 RUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 RUR ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 RUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 RUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 RUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 RUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 RUR ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUR ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
new file mode 100644
index 0000000..6bf3871
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
@@ -0,0 +1,719 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("zh_CN");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "\xEF\xBF\xA5""0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "\xEF\xBF\xA5""0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "\xEF\xBF\xA5""-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "\xEF\xBF\xA5""-0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "\xEF\xBF\xA5""1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "\xEF\xBF\xA5""1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "CNY 0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "CNY 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "CNY -0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "CNY -0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "CNY 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "CNY 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"\xFFE5""0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"\xFFE5""0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"\xFFE5""-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"\xFFE5""-0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"\xFFE5""1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"\xFFE5""1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"CNY 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"CNY 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"CNY -0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"CNY -0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"CNY 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"CNY 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
new file mode 100644
index 0000000..e2f2ecc
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
@@ -0,0 +1,727 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, string_type& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("en_US");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/iterators.h b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/iterators.h
new file mode 100644
index 0000000..5e3ff31
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/iterators.h
@@ -0,0 +1,55 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+#endif
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
new file mode 100644
index 0000000..2e6e2dc
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class InputIterator = istreambuf_iterator<CharT> >
+// class money_get
+//     : public locale::facet
+// {
+// public:
+//     typedef CharT                   char_type;
+//     typedef InputIterator           iter_type;
+//     typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::money_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::money_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::money_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_get<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
new file mode 100644
index 0000000..e667ae0
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// explicit money_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/iterators.h b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/iterators.h
new file mode 100644
index 0000000..791e416
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/iterators.h
@@ -0,0 +1,33 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    output_iterator() : it_() {}
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+#endif
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
new file mode 100644
index 0000000..003a9fe
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
@@ -0,0 +1,490 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("en_US");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
new file mode 100644
index 0000000..34e9ea7
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -0,0 +1,489 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("fr_FR");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,01 -");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 -");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 Eu");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,01 Eu-");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 Eu");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 Eu-");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 Eu-    ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89     Eu-");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "    1 234 567,89 Eu-");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,01 -");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 -");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 EUR ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,01 EUR -");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 EUR ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 EUR -");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 EUR -  ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89   EUR -");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "  1 234 567,89 EUR -");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,01 -");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 -");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 Eu");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,01 Eu-");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 Eu");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 Eu-");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 Eu-    ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89     Eu-");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"    1 234 567,89 Eu-");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,01 -");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 -");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 EUR ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,01 EUR -");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 EUR ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 EUR -");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 EUR -  ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89   EUR -");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"  1 234 567,89 EUR -");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
new file mode 100644
index 0000000..c0baf22
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
@@ -0,0 +1,489 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("ru_RU");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 RUR ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 RUR ");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 RUR ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 RUR ");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 RUR   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89   RUR ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "  -1 234 567,89 RUR ");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 \x440\x443\x431"".");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 \x440\x443\x431"".");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 \x440\x443\x431"".");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \x440\x443\x431"".");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \x440\x443\x431"".  ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89   \x440\x443\x431"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"  -1 234 567,89 \x440\x443\x431"".");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 RUR ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 RUR ");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 RUR ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 RUR ");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 RUR   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89   RUR ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"  -1 234 567,89 RUR ");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
new file mode 100644
index 0000000..80ab190
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
@@ -0,0 +1,489 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("zh_CN");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-1,234,567.89    ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "    \xEF\xBF\xA5""-1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -   1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   CNY -1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      \xFFE5""-1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -   1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   CNY -1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
new file mode 100644
index 0000000..b3ce42c
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
@@ -0,0 +1,490 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               const string_type& units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name("en_US");
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        std::string v = "0";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        std::string v = "-1";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        std::string v = "123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        std::string v = "-123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::string v = "0";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$0.00");
+    }
+    {   // negative one, showbase
+        std::string v = "-1";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$0.01");
+    }
+    {   // positive, showbase
+        std::string v = "123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$1,234,567.89");
+    }
+    {   // negative, showbase
+        std::string v = "-123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::string v = "0";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        std::string v = "-1";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        std::string v = "123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        std::string v = "-123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::string v = "0";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 0.00");
+    }
+    {   // negative one, showbase
+        std::string v = "-1";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 0.01");
+    }
+    {   // positive, showbase
+        std::string v = "123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        std::string v = "-123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::wstring v = L"0";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        std::wstring v = L"-1";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        std::wstring v = L"123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        std::wstring v = L"-123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::wstring v = L"0";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$0.00");
+    }
+    {   // negative one, showbase
+        std::wstring v = L"-1";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$0.01");
+    }
+    {   // positive, showbase
+        std::wstring v = L"123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$1,234,567.89");
+    }
+    {   // negative, showbase
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::wstring v = L"0";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        std::wstring v = L"-1";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        std::wstring v = L"123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        std::wstring v = L"-123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::wstring v = L"0";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 0.00");
+    }
+    {   // negative one, showbase
+        std::wstring v = L"-1";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 0.01");
+    }
+    {   // positive, showbase
+        std::wstring v = L"123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp b/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
new file mode 100644
index 0000000..aee4931
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class money_put
+//     : public locale::facet
+// {
+// public:
+//     typedef CharT                   char_type;
+//     typedef OutputIterator          iter_type;
+//     typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::money_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::money_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::money_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_put<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
new file mode 100644
index 0000000..6e5478e
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type curr_symbol() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.curr_symbol() == "$");
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.curr_symbol() == "USD ");
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.curr_symbol() == L"$");
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.curr_symbol() == L"USD ");
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.curr_symbol() == "Eu");
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.curr_symbol() == "EUR ");
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.curr_symbol() == L"Eu");
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.curr_symbol() == L"EUR ");
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.curr_symbol() == "\xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.curr_symbol() == "RUR ");
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.curr_symbol() == L"\x440\x443\x431"".");
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.curr_symbol() == L"RUR ");
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.curr_symbol() == "\xEF\xBF\xA5");
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.curr_symbol() == "CNY ");
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.curr_symbol() == L"\xFFE5");
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.curr_symbol() == L"CNY ");
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
new file mode 100644
index 0000000..c6e3426
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT decimal_point() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.decimal_point() == L'.');
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.decimal_point() == L'.');
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.decimal_point() == L',');
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.decimal_point() == L',');
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.decimal_point() == L',');
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.decimal_point() == L',');
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.decimal_point() == L'.');
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.decimal_point() == L'.');
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
new file mode 100644
index 0000000..87ed709
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// int frac_digits() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.frac_digits() == 2);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
new file mode 100644
index 0000000..4cb78b6
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string grouping() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.grouping() == "");
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.grouping() == "");
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.grouping() == "");
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.grouping() == "");
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.grouping() == "\3\3");
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.grouping() == "\3\3");
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.grouping() == "\3\3");
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.grouping() == "\3\3");
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
new file mode 100644
index 0000000..6360f19
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
@@ -0,0 +1,218 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f("en_US", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("en_US", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("en_US", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("en_US", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::value);
+        assert(p.field[1] == std::money_base::space);
+        assert(p.field[2] == std::money_base::symbol);
+        assert(p.field[3] == std::money_base::sign);
+    }
+    {
+        Fnt f("fr_FR", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::value);
+        assert(p.field[1] == std::money_base::space);
+        assert(p.field[2] == std::money_base::symbol);
+        assert(p.field[3] == std::money_base::sign);
+    }
+    {
+        Fwf f("fr_FR", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::value);
+        assert(p.field[1] == std::money_base::space);
+        assert(p.field[2] == std::money_base::symbol);
+        assert(p.field[3] == std::money_base::sign);
+    }
+    {
+        Fwt f("fr_FR", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::value);
+        assert(p.field[1] == std::money_base::space);
+        assert(p.field[2] == std::money_base::symbol);
+        assert(p.field[3] == std::money_base::sign);
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f("ru_RU", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f("ru_RU", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f("ru_RU", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("zh_CN", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("zh_CN", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("zh_CN", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
new file mode 100644
index 0000000..da4afcd
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type negative_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.negative_sign() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.negative_sign() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.negative_sign() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.negative_sign() == std::wstring());
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.negative_sign() == L"-");
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
new file mode 100644
index 0000000..3cb5c6c
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
@@ -0,0 +1,218 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f("en_US", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("en_US", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("en_US", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("en_US", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f("fr_FR", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f("fr_FR", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f("fr_FR", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f("ru_RU", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f("ru_RU", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f("ru_RU", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::space);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("zh_CN", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("zh_CN", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("zh_CN", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
new file mode 100644
index 0000000..516aa92
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type positive_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.positive_sign() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.positive_sign() == std::wstring());
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.positive_sign() == L"");
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 0000000..f5ae62d
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT thousands_sep() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+
+    {
+        Fnf f("en_US", 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fnt f("en_US", 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fwf f("en_US", 1);
+        assert(f.thousands_sep() == L',');
+    }
+    {
+        Fwt f("en_US", 1);
+        assert(f.thousands_sep() == L',');
+    }
+
+    {
+        Fnf f("fr_FR", 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fnt f("fr_FR", 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fwf f("fr_FR", 1);
+        assert(f.thousands_sep() == L' ');
+    }
+    {
+        Fwt f("fr_FR", 1);
+        assert(f.thousands_sep() == L' ');
+    }
+
+    {
+        Fnf f("ru_RU", 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fnt f("ru_RU", 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fwf f("ru_RU", 1);
+        assert(f.thousands_sep() == L' ');
+    }
+    {
+        Fwt f("ru_RU", 1);
+        assert(f.thousands_sep() == L' ');
+    }
+
+    {
+        Fnf f("zh_CN", 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fnt f("zh_CN", 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fwf f("zh_CN", 1);
+        assert(f.thousands_sep() == L',');
+    }
+    {
+        Fwt f("zh_CN", 1);
+        assert(f.thousands_sep() == L',');
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
new file mode 100644
index 0000000..438933a
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// explicit moneypunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
new file mode 100644
index 0000000..d3e3d59
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type curr_symbol() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+    {
+        Fwt f(1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
new file mode 100644
index 0000000..a374894
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT decimal_point() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f(1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f(1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f(1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
new file mode 100644
index 0000000..93404a3
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// int frac_digits() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fnt f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwf f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwt f(1);
+        assert(f.frac_digits() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
new file mode 100644
index 0000000..b02492d
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string grouping() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fwt f(1);
+        assert(f.grouping() == std::string());
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
new file mode 100644
index 0000000..16d585f
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
new file mode 100644
index 0000000..da07912
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type negative_sign() const;
+
+// The C++ and C standards are silent.
+//   On this one, commen sense is the guideline.
+//   If customers complain, I'll endeavor to minimize customer complaints
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(1);
+        assert(f.negative_sign() == L"-");
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
new file mode 100644
index 0000000..849316c
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
new file mode 100644
index 0000000..6cec442
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type positive_sign() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.positive_sign() == std::wstring());
+    }
+    {
+        Fwt f(1);
+        assert(f.positive_sign() == std::wstring());
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
new file mode 100644
index 0000000..668273c
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT thousands_sep() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f(1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f(1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f(1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
new file mode 100644
index 0000000..8a82dbb
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_base
+// {
+// public:
+//     enum part {none, space, symbol, sign, value};
+//     struct pattern {char field[4];};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::money_base mb;
+    assert(mb.none == 0);
+    assert(mb.space == 1);
+    assert(mb.symbol == 2);
+    assert(mb.sign == 3);
+    assert(mb.value == 4);
+    assert(sizeof(std::money_base::pattern) == 4);
+    std::money_base::pattern p;
+    p.field[0] = std::money_base::none;
+}
diff --git a/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp b/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
new file mode 100644
index 0000000..95a7d4f
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class _CharT, bool _International = false>
+// class moneypunct
+//     : public locale::facet,
+//       public money_base
+// {
+// public:
+//     typedef _CharT                  char_type;
+//     typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::moneypunct<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::moneypunct<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::money_base, std::moneypunct<char> >::value), "");
+    static_assert((std::is_base_of<std::money_base, std::moneypunct<wchar_t> >::value), "");
+    static_assert((std::is_same<std::moneypunct<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::moneypunct<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::moneypunct<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::moneypunct<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
new file mode 100644
index 0000000..81889e4
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// explicit num_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/iterators.h b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/iterators.h
new file mode 100644
index 0000000..791e416
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/iterators.h
@@ -0,0 +1,33 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    output_iterator() : it_() {}
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+#endif
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
new file mode 100644
index 0000000..d9319ae
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, bool v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "yes";}
+    virtual string_type do_falsename() const {return "no";}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "0");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "1");
+        }
+    }
+    {
+        std::ios ios(0);
+        boolalpha(ios);
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "false");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "true");
+        }
+    }
+    {
+        std::ios ios(0);
+        boolalpha(ios);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "no");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "yes");
+        }
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
new file mode 100644
index 0000000..6ee7094
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
@@ -0,0 +1,17887 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = +0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test2()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test3()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = +0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test4()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test5()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = -0.;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test6()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test7()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = -0.;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test8()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
new file mode 100644
index 0000000..a172c13
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        long v = 0;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        long v = 1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        long v = -1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1");
+    }
+    {
+        std::ios ios(0);
+        long v = -1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1000");
+    }
+    {
+        std::ios ios(0);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***+1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+***1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***-1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-***1_00_0");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
new file mode 100644
index 0000000..58f384e
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
@@ -0,0 +1,26241 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = +0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test2()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test3()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test4()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -INFINITY;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test5()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = std::nan("");
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {}
+            ios.precision(6);
+            {}
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test6()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = +0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test7()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test8()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test9()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test10()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test11()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test12()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+
+    {
+        long double v = +0.;
+    }
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
new file mode 100644
index 0000000..f1886e5
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        long long v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        long long v = 1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        long long v = -1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1");
+    }
+    {
+        std::ios ios(0);
+        long long v = -1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1000");
+    }
+    {
+        std::ios ios(0);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***+1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+***1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***-1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-***1_00_0");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
new file mode 100644
index 0000000..03a3352
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, void* v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        void* v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x0");
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
new file mode 100644
index 0000000..79288df
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
@@ -0,0 +1,374 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        unsigned long v = 0;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = 1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = -1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4294967295" : "18446744073709551615"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = -1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4294966296" : "18446744073709550616"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1_00_0****");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..908aacf
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        unsigned long long v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = 1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = -1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long long) == 4 ? "4294967295" : "18446744073709551615"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = -1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18446744073709550616");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1_00_0****");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp b/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp
new file mode 100644
index 0000000..373df8d
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.nm.put/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> > 
+// class num_put
+//     : public locale::facet
+// {
+// public: 
+//     typedef charT          char_type; 
+//     typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::num_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::num_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::num_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::num_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::num_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::num_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
new file mode 100644
index 0000000..b1b3553
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// explicit num_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_get<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
new file mode 100644
index 0000000..158078a
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, bool& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class p1
+    : public std::numpunct<char>
+{
+public:
+    p1() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "a";}
+    virtual string_type do_falsename() const {return "abb";}
+};
+
+class p2
+    : public std::numpunct<char>
+{
+public:
+    p2() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "a";}
+    virtual string_type do_falsename() const {return "ab";}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "12";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "*12";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+0);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    boolalpha(ios);
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+0);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "true";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "false";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    ios.imbue(std::locale(ios.getloc(), new p1));
+    {
+        const char str[] = "a";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+1),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.eofbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "abc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "acc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    ios.imbue(std::locale(ios.getloc(), new p2));
+    {
+        const char str[] = "a";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+1),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.eofbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "ab";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+2),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.eofbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "abc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "ac";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+2),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
new file mode 100644
index 0000000..569cf7a
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
@@ -0,0 +1,228 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    double v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x125p-1);
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        v = -1;
+        const char str[] = "123_456_78_9;125";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    ios.imbue(std::locale(std::locale(), new my_numpunct));
+    {
+        v = -1;
+        const char str[] = "123_456_78_9;125";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123456789.125);
+    }
+    {
+        v = -1;
+        const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
new file mode 100644
index 0000000..ca0382d
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, float& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    float v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x125p-1);
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
new file mode 100644
index 0000000..971f9e7
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
@@ -0,0 +1,507 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+4);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123";
+        oct(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 83);
+    }
+    {
+        const char str[] = "123";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "0x123";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "0x123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "0123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 83);
+    }
+    dec(ios);
+    ios.imbue(std::locale(std::locale(), new my_numpunct));
+    {
+        v = -1;
+        const char str[] = "123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+_1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1__";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+_1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+__1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+_1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "__+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_2";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+_12";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+1__2";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_3";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23_4";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+123_4";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_34";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_34_5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 12345);
+    }
+    {
+        v = -1;
+        const char str[] = "+123_45_6";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123456);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23_45_6";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123456);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_234_56_7";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "-1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == std::numeric_limits<long>::max());
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
new file mode 100644
index 0000000..d8b6fb5
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long double v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x125p-1);
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
new file mode 100644
index 0000000..f2d2cf0
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    {
+        const char str[] = "-1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0x7FFFFFFFFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x7FFFFFFFFFFFFFFFLL);
+    }
+    {
+        const char str[] = "-0x8000000000000000";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x8000000000000000LL);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
new file mode 100644
index 0000000..c57a967
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, void*& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    {
+        const char str[] = "0x0";
+        std::ios_base::iostate err = ios.goodbit;
+        void* p;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, p);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(p == 0);
+    }
+    {
+        const char str[] = "0x73";
+        std::ios_base::iostate err = ios.goodbit;
+        void* p;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, p);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(p == (void*)0x73);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
new file mode 100644
index 0000000..02e4a41
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned int& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned int v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFF);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
new file mode 100644
index 0000000..9a623d6
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFF);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..e2347a6
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned long long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFFFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFFFFFFFFFFULL);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
new file mode 100644
index 0000000..8249d1a
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned short& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned short v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter = 
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFF);
+    }
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/iterators.h b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/iterators.h
new file mode 100644
index 0000000..85332ac
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/iterators.h
@@ -0,0 +1,251 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+#endif
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp b/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp
new file mode 100644
index 0000000..0b8c40d
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/locale.num.get/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class InputIterator = istreambuf_iterator<charT> > 
+// class num_get
+//     : public locale::facet
+// {
+// public: 
+//     typedef charT char_type; 
+//     typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::num_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::num_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::num_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::num_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::num_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::num_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp
new file mode 100644
index 0000000..8b69ecf
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_get_byname<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    {
+        const my_facet f("en_US", 1);
+        assert(f.date_order() == std::time_base::mdy);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        assert(f.date_order() == std::time_base::ymd);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp
new file mode 100644
index 0000000..1b35be9
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_get_byname<wchar_t, input_iterator<const wchar_t*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    {
+        const my_facet f("en_US", 1);
+        assert(f.date_order() == std::time_base::mdy);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        assert(f.date_order() == std::time_base::ymd);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
new file mode 100644
index 0000000..03a41d0
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "06/10/2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "2009/06/10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
new file mode 100644
index 0000000..b1750cb
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"06/10/2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"2009/06/10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
new file mode 100644
index 0000000..e5c0182
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "juin";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "\xE5\x85\xAD\xE6\x9C\x88";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
new file mode 100644
index 0000000..5b2c829
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+typedef std::time_put_byname<wchar_t, wchar_t*> F2;
+class my_facet2
+    : public F2
+{
+public:
+    explicit my_facet2(const std::string& nm, std::size_t refs = 0)
+        : F2(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"juin";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"\x438\x44E\x43D\x44F";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"\x516D\x6708";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
new file mode 100644
index 0000000..6035c7a
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f, 
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "Sat Dec 31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "Sam 31 d""\xC3\xA9""c 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "\xD1\x81\xD1\x83\xD0\xB1\xD0\xB1"
+                          "\xD0\xBE\xD1\x82\xD0\xB0"
+                          ", 31 "
+                          "\xD0\xB4\xD0\xB5\xD0\xBA\xD0\xB0"
+                          "\xD0\xB1\xD1\x80\xD1\x8F"
+                          " 2061 "
+                          "\xD0\xB3"
+                          ". 23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "\xE5\x85\xAD"
+                          " 12/31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "23""\xE6\x97\xB6""55""\xE5\x88\x86""59""\xE7\xA7\x92";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
new file mode 100644
index 0000000..6a1fd67
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f, 
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"Sat Dec 31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"Sam 31 d""\xE9""c 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"\x441\x443\x431\x431\x43E\x442\x430"
+                          ", 31 "
+                          "\x434\x435\x43A\x430\x431\x440\x44F"
+                          " 2061 "
+                          "\x433"
+                          ". 23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"\x516D"
+                          " 12/31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"23""\x65F6""55""\x5206""59""\x79D2";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp
new file mode 100644
index 0000000..b109a25
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp
new file mode 100644
index 0000000..6ccd733
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
new file mode 100644
index 0000000..0124b89
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "Monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "Lundi";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "\xD0\xBF\xD0\xBE\xD0\xBD\xD0\xB5"
+                          "\xD0\xB4\xD0\xB5\xD0\xBB\xD1\x8C"
+                          "\xD0\xBD\xD0\xB8\xD0\xBA";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "\xE6\x98\x9F\xE6\x9C\x9F\xE4\xB8\x80";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
new file mode 100644
index 0000000..253fb2c
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"Monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"Lundi";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"\x661F\x671F\x4E00";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
new file mode 100644
index 0000000..1ac9118
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str, 
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
new file mode 100644
index 0000000..6ad7943
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str, 
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f("en_US", 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get.byname/iterators.h b/test/localization/locale.categories/category.time/locale.time.get.byname/iterators.h
new file mode 100644
index 0000000..5e3ff31
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get.byname/iterators.h
@@ -0,0 +1,55 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+#endif
diff --git a/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
new file mode 100644
index 0000000..388c00b
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// explicit time_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_get<char, const char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
new file mode 100644
index 0000000..2480bf9
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    assert(f.date_order() == std::time_base::mdy);
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
new file mode 100644
index 0000000..87f9e7a
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "5/5/5";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 5);
+        assert(t.tm_year == 105);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
new file mode 100644
index 0000000..c1ca59a
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"5/5/5";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 5);
+        assert(t.tm_year == 105);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
new file mode 100644
index 0000000..b5f8caa
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err, tm *t,
+//     const char_type *fmt, const char_type *fmtend) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "2009 May 9, 10:27pm";
+        const char fmt[] = "%Y %b %d, %I:%M%p";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 109);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 9);
+        assert(t.tm_hour == 22);
+        assert(t.tm_min == 27);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "10:27PM May 9, 2009";
+        const char fmt[] = "%I:%M%p %b %d, %Y";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 109);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 9);
+        assert(t.tm_hour == 22);
+        assert(t.tm_min == 27);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
new file mode 100644
index 0000000..0df8310
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "Jan";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Feb";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mar";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Apr";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Aug";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Sep";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Oct";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Nov";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Dec";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "January";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "February";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "March";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "April";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "July";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "August";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "September";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "October";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "November";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "December";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Decemper";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
new file mode 100644
index 0000000..bf90ddb
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"Jan";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Feb";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mar";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Apr";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Jun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Aug";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Sep";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Oct";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Nov";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Dec";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"January";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"February";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"March";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"April";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"July";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"August";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"September";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"October";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"November";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"December";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Decemper";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
new file mode 100644
index 0000000..a476778
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f, 
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'a');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "wednesdaY";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'A');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'b');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'B');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thu Jun  6 09:49:10 2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 4);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 6);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "11";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'd');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mday == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2/1/1";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'D');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 1);
+        assert(t.tm_mday == 1);
+        assert(t.tm_year == 101);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "11";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'e');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mday == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'h');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "19";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'H');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 19);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'm');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'M');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_min == 59);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "\t\n ";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'n');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49:10 PM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49:10 AM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12:49:10 AM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12:49:10 PM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 12);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'R');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'S');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "\t\n ";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 't');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "21:49:10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'T');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "3";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'w');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "06/06/09";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'x');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 6);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "21:49:10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'y');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 168);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'Y');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == -1832);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "%";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, '%');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
new file mode 100644
index 0000000..843d04e
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "0:0:0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "23:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 23);
+        assert(t.tm_min == 59);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "24:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+2);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char in[] = "23:60:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char in[] = "23:59:61";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "2:43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_hour == 2);
+        assert(t.tm_min == 43);
+        assert(t.tm_sec == 22);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "2.43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+1);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
new file mode 100644
index 0000000..0b74804
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"0:0:0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"23:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 23);
+        assert(t.tm_min == 59);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"24:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+2);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const wchar_t in[] = L"23:60:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const wchar_t in[] = L"23:59:61";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"2:43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_hour == 2);
+        assert(t.tm_min == 43);
+        assert(t.tm_sec == 22);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"2.43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+1);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
new file mode 100644
index 0000000..d125f10
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "Sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Suny";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "Sund";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "sunday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mony";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "Mond";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Tue";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Tuesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Wed";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Wednesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thu";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thursday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Fri";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Friday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Sat";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Saturday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
new file mode 100644
index 0000000..cb79313
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"Sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Suny";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"Sund";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"sunday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mony";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"Mond";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Tue";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Tuesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Wed";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Wednesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Thu";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Thursday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Fri";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Friday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Sat";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Saturday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
new file mode 100644
index 0000000..168a435
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str, 
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "00";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 101);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 168);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "69";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 69);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "99";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 99);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "100";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == -1800);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1900";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1968";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 68);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2000";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2999c";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-2);
+        assert(t.tm_year == 1099);
+        assert(err == std::ios_base::goodbit);
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/iterators.h b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/iterators.h
new file mode 100644
index 0000000..5e3ff31
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/iterators.h
@@ -0,0 +1,55 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+#endif
diff --git a/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
new file mode 100644
index 0000000..af65a86
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+//     enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::time_base::dateorder d = std::time_base::no_order;
+    assert(std::time_base::no_order == 0);
+    assert(std::time_base::dmy == 1);
+    assert(std::time_base::mdy == 2);
+    assert(std::time_base::ymd == 3);
+    assert(std::time_base::ydm == 4);
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp b/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
new file mode 100644
index 0000000..e6268fa
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+//     enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+// 
+// template <class charT, class InputIterator = istreambuf_iterator<charT> > 
+// class time_get
+//     : public locale::facet,
+//       public time_base
+// {
+// public: 
+//     typedef charT         char_type; 
+//     typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::time_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::time_get<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::time_base, std::time_get<char> >::value), "");
+    static_assert((std::is_base_of<std::time_base, std::time_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::time_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::time_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::time_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::time_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put.byname/iterators.h b/test/localization/locale.categories/category.time/locale.time.put.byname/iterators.h
new file mode 100644
index 0000000..791e416
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put.byname/iterators.h
@@ -0,0 +1,33 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    output_iterator() : it_() {}
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+#endif
diff --git a/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
new file mode 100644
index 0000000..9f1640b
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put.byname/put1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class time_put_byname
+//     : public time_put<CharT, OutputIterator>
+// {
+// public:
+//     explicit time_put_byname(const char* nm, size_t refs = 0);
+//     explicit time_put_byname(const string& nm, size_t refs = 0);
+// 
+// protected:
+//     ~time_put_byname();
+// };
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_put_byname<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    tm t;
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        const my_facet f("en_US", 1);
+        std::string pat("Today is %A which is abreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "Today is Saturday which is abreviated Sat.");
+    }
+    {
+        const my_facet f("fr_FR", 1);
+        std::string pat("Today is %A which is abreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "Today is Samedi which is abreviated Sam.");
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
new file mode 100644
index 0000000..713a956
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// explicit time_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/iterators.h b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/iterators.h
new file mode 100644
index 0000000..791e416
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/iterators.h
@@ -0,0 +1,33 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    output_iterator() : it_() {}
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+#endif
diff --git a/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
new file mode 100644
index 0000000..d67314a
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t, 
+//               const charT* pattern, const charT* pat_end) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    char str[200];
+    output_iterator<char*> iter;
+    tm t;
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        std::string pat("Today is %A which is abreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "Today is Saturday which is abreviated Sat.");
+    }
+    {
+        std::string pat("The number of the month is %Om.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "The number of the month is 05.");
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
new file mode 100644
index 0000000..ff3a3dd
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
@@ -0,0 +1,367 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t, 
+//               char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    char str[200];
+    output_iterator<char*> iter;
+    tm t;
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'A');
+        std::string ex(str, iter.base());
+        assert(ex == "Saturday");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'a');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'b');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C');
+        std::string ex(str, iter.base());
+        assert(ex == "20");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat May  2 13:03:06 2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'D');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd');
+        std::string ex(str, iter.base());
+        assert(ex == "02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat May  2 13:03:06 2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "20");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == " 2");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "01");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "05");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "52");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e');
+        std::string ex(str, iter.base());
+        assert(ex == " 2");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'F');
+        std::string ex(str, iter.base());
+        assert(ex == "2009-05-02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'G');
+        std::string ex(str, iter.base());
+        assert(ex == "2008");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'g');
+        std::string ex(str, iter.base());
+        assert(ex == "08");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'h');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I');
+        std::string ex(str, iter.base());
+        assert(ex == "01");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'j');
+        std::string ex(str, iter.base());
+        assert(ex == "000");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'k');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'l');
+        std::string ex(str, iter.base());
+        assert(ex == " 1");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M');
+        std::string ex(str, iter.base());
+        assert(ex == "03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm');
+        std::string ex(str, iter.base());
+        assert(ex == "05");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'n');
+        std::string ex(str, iter.base());
+        assert(ex == "\n");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'p');
+        std::string ex(str, iter.base());
+        assert(ex == "PM");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'R');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'r');
+        std::string ex(str, iter.base());
+        assert(ex == "01:03:06 PM");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S');
+        std::string ex(str, iter.base());
+        assert(ex == "06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 's');
+        std::string ex(str, iter.base());
+//        assert(ex == "1241283786");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'T');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 't');
+        std::string ex(str, iter.base());
+        assert(ex == "\t");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V');
+        std::string ex(str, iter.base());
+        assert(ex == "52");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'v');
+        std::string ex(str, iter.base());
+        assert(ex == " 2-May-2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y');
+        std::string ex(str, iter.base());
+        assert(ex == "2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Z');
+        std::string ex(str, iter.base());
+//        assert(ex == "EDT");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'z');
+        std::string ex(str, iter.base());
+//        assert(ex == "-0400");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '+');
+        std::string ex(str, iter.base());
+//        assert(ex == "Sat May  2 13:03:06 EDT 2009");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%');
+        std::string ex(str, iter.base());
+        assert(ex == "%");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%', 'J');
+        std::string ex(str, iter.base());
+        assert(ex == "J%");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'J');
+        std::string ex(str, iter.base());
+        assert(ex == "J");
+    }
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp b/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp
new file mode 100644
index 0000000..3eaa76f
--- /dev/null
+++ b/test/localization/locale.categories/category.time/locale.time.put/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> > 
+// class time_put
+//     : public locale::facet
+// {
+// public: 
+//     typedef charT          char_type; 
+//     typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::time_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::time_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::time_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::time_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::time_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::time_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp b/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
new file mode 100644
index 0000000..bd2fcc6
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == '.');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L'.');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == '.');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L'.');
+        }
+    }
+    {
+        std::locale l("fr_FR");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L',');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
new file mode 100644
index 0000000..8d91c34
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// string grouping() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "");
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\3\3");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\3\3");
+        }
+    }
+    {
+        std::locale l("fr_FR");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\x7F");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\x7F");
+        }
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 0000000..ff46d67
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type thousands_sep() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+    {
+        std::locale l("en_US");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+    {
+        std::locale l("fr_FR");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
new file mode 100644
index 0000000..b6ea246
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// explicit numpunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::numpunct<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::numpunct<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<char>);
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        my_facet<char> f(1);
+        assert(my_facet<char>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<char>::count == 1);
+        }
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp
new file mode 100644
index 0000000..eecb395
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.decimal_point() == '.');
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.decimal_point() == L'.');
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp
new file mode 100644
index 0000000..8069463
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type falsename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.falsename() == std::string("false"));
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.falsename() == std::wstring(L"false"));
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp
new file mode 100644
index 0000000..604e0c5
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string grouping() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.grouping() == std::string());
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.grouping() == std::string());
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp
new file mode 100644
index 0000000..37abfc5
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type thousands_sep() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.thousands_sep() == ',');
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.thousands_sep() == L',');
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp
new file mode 100644
index 0000000..2f1b4ab
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type truename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.truename() == std::string("true"));
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.truename() == std::wstring(L"true"));
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp b/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
new file mode 100644
index 0000000..d7b6419
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> 
+// class numpunct
+//     : public locale::facet
+// { 
+// public: 
+//     typedef charT char_type; 
+//     typedef basic_string<charT> string_type; 
+//     static locale::id id;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::numpunct<char> >(l));
+        const std::numpunct<char>& f = std::use_facet<std::numpunct<char> >(l);
+        {
+            (void)std::numpunct<char>::id;
+        }
+        static_assert((std::is_same<std::numpunct<char>::char_type, char>::value), "");
+        static_assert((std::is_same<std::numpunct<char>::string_type, std::string>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::numpunct<char> >::value), "");
+    }
+    {
+        assert(std::has_facet<std::numpunct<wchar_t> >(l));
+        const std::numpunct<wchar_t>& f = std::use_facet<std::numpunct<wchar_t> >(l);
+        {
+            (void)std::numpunct<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::numpunct<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_same<std::numpunct<wchar_t>::string_type, std::wstring>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::numpunct<wchar_t> >::value), "");
+    }
+}
diff --git a/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp b/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp b/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locale.syn/nothing_to_do.pass.cpp b/test/localization/locale.syn/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locale.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp b/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp
new file mode 100644
index 0000000..70bb6ec
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalnum (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isalnum(' ', l));
+    assert(!std::isalnum('<', l));
+    assert(!std::isalnum('\x8', l));
+    assert( std::isalnum('A', l));
+    assert( std::isalnum('a', l));
+    assert( std::isalnum('z', l));
+    assert( std::isalnum('3', l));
+    assert(!std::isalnum('.', l));
+    assert( std::isalnum('f', l));
+    assert( std::isalnum('9', l));
+    assert(!std::isalnum('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp b/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp
new file mode 100644
index 0000000..fa7842d
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalpha (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isalpha(' ', l));
+    assert(!std::isalpha('<', l));
+    assert(!std::isalpha('\x8', l));
+    assert( std::isalpha('A', l));
+    assert( std::isalpha('a', l));
+    assert( std::isalpha('z', l));
+    assert(!std::isalpha('3', l));
+    assert(!std::isalpha('.', l));
+    assert( std::isalpha('f', l));
+    assert(!std::isalpha('9', l));
+    assert(!std::isalpha('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp b/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
new file mode 100644
index 0000000..6179c07
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool iscntrl (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::iscntrl(' ', l));
+    assert(!std::iscntrl('<', l));
+    assert( std::iscntrl('\x8', l));
+    assert(!std::iscntrl('A', l));
+    assert(!std::iscntrl('a', l));
+    assert(!std::iscntrl('z', l));
+    assert(!std::iscntrl('3', l));
+    assert(!std::iscntrl('.', l));
+    assert(!std::iscntrl('f', l));
+    assert(!std::iscntrl('9', l));
+    assert(!std::iscntrl('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp b/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp
new file mode 100644
index 0000000..05a4383
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isdigit(' ', l));
+    assert(!std::isdigit('<', l));
+    assert(!std::isdigit('\x8', l));
+    assert(!std::isdigit('A', l));
+    assert(!std::isdigit('a', l));
+    assert(!std::isdigit('z', l));
+    assert( std::isdigit('3', l));
+    assert(!std::isdigit('.', l));
+    assert(!std::isdigit('f', l));
+    assert( std::isdigit('9', l));
+    assert(!std::isdigit('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp b/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp
new file mode 100644
index 0000000..03a19c4
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isgraph (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isgraph(' ', l));
+    assert( std::isgraph('<', l));
+    assert(!std::isgraph('\x8', l));
+    assert( std::isgraph('A', l));
+    assert( std::isgraph('a', l));
+    assert( std::isgraph('z', l));
+    assert( std::isgraph('3', l));
+    assert( std::isgraph('.', l));
+    assert( std::isgraph('f', l));
+    assert( std::isgraph('9', l));
+    assert( std::isgraph('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/islower.pass.cpp b/test/localization/locales/locale.convenience/classification/islower.pass.cpp
new file mode 100644
index 0000000..7327bb5
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/islower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool islower (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::islower(' ', l));
+    assert(!std::islower('<', l));
+    assert(!std::islower('\x8', l));
+    assert(!std::islower('A', l));
+    assert( std::islower('a', l));
+    assert( std::islower('z', l));
+    assert(!std::islower('3', l));
+    assert(!std::islower('.', l));
+    assert( std::islower('f', l));
+    assert(!std::islower('9', l));
+    assert(!std::islower('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isprint.pass.cpp b/test/localization/locales/locale.convenience/classification/isprint.pass.cpp
new file mode 100644
index 0000000..828139d
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isprint.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isprint (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert( std::isprint(' ', l));
+    assert( std::isprint('<', l));
+    assert(!std::isprint('\x8', l));
+    assert( std::isprint('A', l));
+    assert( std::isprint('a', l));
+    assert( std::isprint('z', l));
+    assert( std::isprint('3', l));
+    assert( std::isprint('.', l));
+    assert( std::isprint('f', l));
+    assert( std::isprint('9', l));
+    assert( std::isprint('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp b/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp
new file mode 100644
index 0000000..426f0f2
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool ispunct (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::ispunct(' ', l));
+    assert( std::ispunct('<', l));
+    assert(!std::ispunct('\x8', l));
+    assert(!std::ispunct('A', l));
+    assert(!std::ispunct('a', l));
+    assert(!std::ispunct('z', l));
+    assert(!std::ispunct('3', l));
+    assert( std::ispunct('.', l));
+    assert(!std::ispunct('f', l));
+    assert(!std::ispunct('9', l));
+    assert( std::ispunct('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isspace.pass.cpp b/test/localization/locales/locale.convenience/classification/isspace.pass.cpp
new file mode 100644
index 0000000..cb4d2ed
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isspace.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isspace (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert( std::isspace(' ', l));
+    assert(!std::isspace('<', l));
+    assert(!std::isspace('\x8', l));
+    assert(!std::isspace('A', l));
+    assert(!std::isspace('a', l));
+    assert(!std::isspace('z', l));
+    assert(!std::isspace('3', l));
+    assert(!std::isspace('.', l));
+    assert(!std::isspace('f', l));
+    assert(!std::isspace('9', l));
+    assert(!std::isspace('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isupper.pass.cpp b/test/localization/locales/locale.convenience/classification/isupper.pass.cpp
new file mode 100644
index 0000000..2a8dc8f
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isupper (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isupper(' ', l));
+    assert(!std::isupper('<', l));
+    assert(!std::isupper('\x8', l));
+    assert( std::isupper('A', l));
+    assert(!std::isupper('a', l));
+    assert(!std::isupper('z', l));
+    assert(!std::isupper('3', l));
+    assert(!std::isupper('.', l));
+    assert(!std::isupper('f', l));
+    assert(!std::isupper('9', l));
+    assert(!std::isupper('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp b/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
new file mode 100644
index 0000000..691c95b
--- /dev/null
+++ b/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isxdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isxdigit(' ', l));
+    assert(!std::isxdigit('<', l));
+    assert(!std::isxdigit('\x8', l));
+    assert( std::isxdigit('A', l));
+    assert( std::isxdigit('a', l));
+    assert(!std::isxdigit('z', l));
+    assert( std::isxdigit('3', l));
+    assert(!std::isxdigit('.', l));
+    assert( std::isxdigit('f', l));
+    assert( std::isxdigit('9', l));
+    assert(!std::isxdigit('+', l));
+}
diff --git a/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp b/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
new file mode 100644
index 0000000..6842081
--- /dev/null
+++ b/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT tolower(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(std::tolower(' ', l) == ' ');
+    assert(std::tolower('<', l) == '<');
+    assert(std::tolower('\x8', l) == '\x8');
+    assert(std::tolower('A', l) == 'a');
+    assert(std::tolower('a', l) == 'a');
+    assert(std::tolower('z', l) == 'z');
+    assert(std::tolower('3', l) == '3');
+    assert(std::tolower('.', l) == '.');
+    assert(std::tolower('f', l) == 'f');
+    assert(std::tolower('9', l) == '9');
+    assert(std::tolower('+', l) == '+');
+}
diff --git a/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp b/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
new file mode 100644
index 0000000..5b341a2
--- /dev/null
+++ b/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT toupper(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(std::toupper(' ', l) == ' ');
+    assert(std::toupper('<', l) == '<');
+    assert(std::toupper('\x8', l) == '\x8');
+    assert(std::toupper('A', l) == 'A');
+    assert(std::toupper('a', l) == 'A');
+    assert(std::toupper('z', l) == 'Z');
+    assert(std::toupper('3', l) == '3');
+    assert(std::toupper('.', l) == '.');
+    assert(std::toupper('f', l) == 'F');
+    assert(std::toupper('9', l) == '9');
+    assert(std::toupper('+', l) == '+');
+}
diff --git a/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp b/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp b/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locales/locale.global.templates/has_facet.pass.cpp b/test/localization/locales/locale.global.templates/has_facet.pass.cpp
new file mode 100644
index 0000000..223d958
--- /dev/null
+++ b/test/localization/locales/locale.global.templates/has_facet.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> bool has_facet(const locale& loc) throw();
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+    : public std::locale::facet
+{
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+    std::locale loc;
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(!std::has_facet<my_facet>(loc));
+    std::locale loc2(loc, new my_facet);
+    assert(std::has_facet<my_facet>(loc2));
+}
diff --git a/test/localization/locales/locale.global.templates/use_facet.pass.cpp b/test/localization/locales/locale.global.templates/use_facet.pass.cpp
new file mode 100644
index 0000000..35e4715
--- /dev/null
+++ b/test/localization/locales/locale.global.templates/use_facet.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> const Facet& use_facet(const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int facet_count = 0;
+
+struct my_facet
+    : public std::locale::facet
+{
+    static std::locale::id id;
+
+    bool im_alive;
+
+    my_facet() : im_alive(true) {++facet_count;}
+    ~my_facet() {im_alive = false; --facet_count;}
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+    try
+    {
+        const my_facet& f = std::use_facet<my_facet>(std::locale());
+        assert(false);
+    }
+    catch (std::bad_cast&)
+    {
+    }
+    const my_facet* fp = 0;
+    {
+        std::locale loc(std::locale(), new my_facet);
+        const my_facet& f = std::use_facet<my_facet>(loc);
+        assert(f.im_alive);
+        fp = &f;
+        assert(fp->im_alive);
+        assert(facet_count == 1);
+    }
+    assert(facet_count == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/assign.pass.cpp b/test/localization/locales/locale/locale.cons/assign.pass.cpp
new file mode 100644
index 0000000..7b065a9
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/assign.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// const locale& operator=(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("ru_RU");
+        std::locale loc2;
+        loc2 = loc;
+        assert(loc == loc2);
+        check(loc);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp
new file mode 100644
index 0000000..b3b581a
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// explicit locale(const char* std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("ru_RU");
+        check(loc);
+        std::locale loc2("ru_RU");
+        check(loc2);
+        assert(loc == loc2);
+        std::locale loc3("zh_CN");
+        check(loc3);
+        assert(!(loc == loc3));
+        assert(loc != loc3);
+        try
+        {
+            std::locale((const char*)0);
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+        try
+        {
+            std::locale("spazbot");
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+        std::locale ok("");
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/copy.pass.cpp b/test/localization/locales/locale/locale.cons/copy.pass.cpp
new file mode 100644
index 0000000..3b9ee47
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/copy.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("fr_FR");
+        std::locale loc2 = loc;
+        assert(loc == loc2);
+        check(loc);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/default.pass.cpp b/test/localization/locales/locale/locale.cons/default.pass.cpp
new file mode 100644
index 0000000..2cc2cc5
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale() throw();
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    int ok;
+    {
+        std::locale loc;
+        assert(new_called == 0);
+        assert(loc.name() == "C");
+        assert(new_called == 0);
+        check(loc);
+        assert(new_called == 0);
+        assert(std::locale::global(std::locale("en_US")) == loc);
+        ok = new_called;
+        std::locale loc2;
+        assert(new_called == ok);
+        check(loc2);
+        assert(new_called == ok);
+        assert(loc2 == std::locale("en_US"));
+        assert(new_called == ok);
+    }
+    assert(new_called == ok);
+}
diff --git a/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp b/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
new file mode 100644
index 0000000..c8fb0e1
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const char* std_name, category);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("ru_RU");
+        check(loc);
+        std::locale loc2(loc, "en_US", std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp b/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
new file mode 100644
index 0000000..4bf57aa
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> locale(const locale& other, Facet* f);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+    : public std::locale::facet
+{
+    int test() const {return 5;}
+
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+    {
+        std::locale loc("ru_RU");
+        check(loc);
+        std::locale loc2(loc, new my_facet);
+        check(loc2);
+        assert((std::has_facet<my_facet>(loc2)));
+        const my_facet& f = std::use_facet<my_facet>(loc2);
+        assert(f.test() == 5);
+    }
+    assert(new_called == 0);
+}
+{
+    {
+        std::locale loc;
+        check(loc);
+        std::locale loc2(loc, (std::ctype<char>*)0);
+        check(loc2);
+        assert(loc == loc2);
+    }
+    assert(new_called == 0);
+}
+}
diff --git a/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp b/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
new file mode 100644
index 0000000..fe0604b
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const locale& one, category cats);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("ru_RU");
+        check(loc);
+        std::locale loc2(loc, std::locale("en_US"), std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
new file mode 100644
index 0000000..b7c2d43
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const string& std_name, category cat);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc("ru_RU");
+        check(loc);
+        std::locale loc2(loc, std::string("en_US"), std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.cons/string.pass.cpp b/test/localization/locales/locale/locale.cons/string.pass.cpp
new file mode 100644
index 0000000..949ccc3
--- /dev/null
+++ b/test/localization/locales/locale/locale.cons/string.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// explicit locale(const string& std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(std::string("ru_RU"));
+        check(loc);
+        std::locale loc2(std::string("ru_RU"));
+        check(loc2);
+        assert(loc == loc2);
+        std::locale loc3(std::string("zh_CN"));
+        check(loc3);
+        assert(!(loc == loc3));
+        assert(loc != loc3);
+    }
+    assert(new_called == 0);
+}
diff --git a/test/localization/locales/locale/locale.members/combine.pass.cpp b/test/localization/locales/locale/locale.members/combine.pass.cpp
new file mode 100644
index 0000000..223ff26
--- /dev/null
+++ b/test/localization/locales/locale/locale.members/combine.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> locale combine(const locale& other) const;
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+    : public std::locale::facet
+{
+    int test() const {return 5;}
+
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+    {
+        std::locale loc;
+        std::locale loc2(loc, new my_facet);
+        std::locale loc3 = loc.combine<my_facet>(loc2);
+        check(loc3);
+        assert(loc3.name() == "*");
+        assert((std::has_facet<my_facet>(loc3)));
+        const my_facet& f = std::use_facet<my_facet>(loc3);
+        assert(f.test() == 5);
+    }
+    assert(new_called == 0);
+}
+{
+    {
+        std::locale loc;
+        std::locale loc2;
+        try
+        {
+            std::locale loc3 = loc.combine<my_facet>(loc2);
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+    }
+    assert(new_called == 0);
+}
+}
diff --git a/test/localization/locales/locale/locale.members/name.pass.cpp b/test/localization/locales/locale/locale.members/name.pass.cpp
new file mode 100644
index 0000000..6bf3788
--- /dev/null
+++ b/test/localization/locales/locale/locale.members/name.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale loc;
+        assert(loc.name() == "C");
+    }
+    {
+        std::locale loc("en_US");
+        assert(loc.name() == "en_US");
+    }
+}
diff --git a/test/localization/locales/locale/locale.operators/compare.pass.cpp b/test/localization/locales/locale/locale.operators/compare.pass.cpp
new file mode 100644
index 0000000..74c627f
--- /dev/null
+++ b/test/localization/locales/locale/locale.operators/compare.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class Traits, class Allocator> 
+//   bool operator()(const basic_string<charT,Traits,Allocator>& s1, 
+//                   const basic_string<charT,Traits,Allocator>& s2) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l;
+        {
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(l(s3, s2));
+        }
+        {
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(l(s3, s2));
+        }
+    }
+}
diff --git a/test/localization/locales/locale/locale.operators/eq.pass.cpp b/test/localization/locales/locale/locale.operators/eq.pass.cpp
new file mode 100644
index 0000000..5a04804
--- /dev/null
+++ b/test/localization/locales/locale/locale.operators/eq.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale cloc;
+    std::locale copy(cloc);
+    std::locale n1("en_US");
+    std::locale n2("en_US");
+    std::locale noname1 = n1.combine<std::ctype<char> >(cloc);
+    std::locale nonamec = noname1;
+    std::locale noname2 = n1.combine<std::ctype<char> >(cloc);
+
+    assert(cloc == cloc);
+    assert(cloc == copy);
+    assert(cloc != n1);
+    assert(cloc != n2);
+    assert(cloc != noname1);
+    assert(cloc != nonamec);
+    assert(cloc != noname2);
+
+    assert(copy == cloc);
+    assert(copy == copy);
+    assert(copy != n1);
+    assert(copy != n2);
+    assert(copy != noname1);
+    assert(copy != nonamec);
+    assert(copy != noname2);
+
+    assert(n1 != cloc);
+    assert(n1 != copy);
+    assert(n1 == n1);
+    assert(n1 == n2);
+    assert(n1 != noname1);
+    assert(n1 != nonamec);
+    assert(n1 != noname2);
+
+    assert(n2 != cloc);
+    assert(n2 != copy);
+    assert(n2 == n1);
+    assert(n2 == n2);
+    assert(n2 != noname1);
+    assert(n2 != nonamec);
+    assert(n2 != noname2);
+
+    assert(noname1 != cloc);
+    assert(noname1 != copy);
+    assert(noname1 != n1);
+    assert(noname1 != n2);
+    assert(noname1 == noname1);
+    assert(noname1 == nonamec);
+    assert(noname1 != noname2);
+
+    assert(nonamec != cloc);
+    assert(nonamec != copy);
+    assert(nonamec != n1);
+    assert(nonamec != n2);
+    assert(nonamec == noname1);
+    assert(nonamec == nonamec);
+    assert(nonamec != noname2);
+
+    assert(noname2 != cloc);
+    assert(noname2 != copy);
+    assert(noname2 != n1);
+    assert(noname2 != n2);
+    assert(noname2 != noname1);
+    assert(noname2 != nonamec);
+    assert(noname2 == noname2);
+}
diff --git a/test/localization/locales/locale/locale.statics/classic.pass.cpp b/test/localization/locales/locale/locale.statics/classic.pass.cpp
new file mode 100644
index 0000000..2738bf8
--- /dev/null
+++ b/test/localization/locales/locale/locale.statics/classic.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    std::locale loc = std::locale::classic();
+    assert(loc.name() == "C");
+    assert(loc == std::locale("C"));
+    check(loc);
+    check(std::locale("C"));
+}
diff --git a/test/localization/locales/locale/locale.statics/global.pass.cpp b/test/localization/locales/locale/locale.statics/global.pass.cpp
new file mode 100644
index 0000000..42735e9
--- /dev/null
+++ b/test/localization/locales/locale/locale.statics/global.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    std::locale loc;
+    assert(loc.name() == "C");
+    check(loc);
+    assert(std::locale::global(std::locale("en_US")) == loc);
+    std::locale loc2;
+    check(loc2);
+    assert(loc2 == std::locale("en_US"));
+}
diff --git a/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp b/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp
new file mode 100644
index 0000000..6a434ec
--- /dev/null
+++ b/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// typedef int category;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_same<std::locale::category, int>::value), "");
+    assert(std::locale::none == 0);
+    assert(std::locale::collate);
+    assert(std::locale::ctype);
+    assert(std::locale::monetary);
+    assert(std::locale::numeric);
+    assert(std::locale::time);
+    assert(std::locale::messages);
+    assert((std::locale::collate
+          & std::locale::ctype
+          & std::locale::monetary
+          & std::locale::numeric
+          & std::locale::time
+          & std::locale::messages) == 0);
+    assert((std::locale::collate
+          | std::locale::ctype
+          | std::locale::monetary
+          | std::locale::numeric
+          | std::locale::time
+          | std::locale::messages)
+         == std::locale::all);
+}
diff --git a/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
new file mode 100644
index 0000000..355674a
--- /dev/null
+++ b/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::facet
+// { 
+// protected: 
+//     explicit facet(size_t refs = 0); 
+//     virtual ~facet(); 
+//     facet(const facet&) = delete; 
+//     void operator=(const facet&) = delete; 
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+    : public std::locale::facet
+{
+    static int count;
+    my_facet(unsigned refs = 0)
+        : std::locale::facet(refs)
+        {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    my_facet* f = new my_facet;
+    f->__add_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 0);
+    f = new my_facet(1);
+    f->__add_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 0);
+}
diff --git a/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp
new file mode 100644
index 0000000..874766a
--- /dev/null
+++ b/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::id
+// {
+// public: 
+//     id();
+//     void operator=(const id&) = delete;
+//     id(const id&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+std::locale::id id0;
+std::locale::id id2;
+std::locale::id id1;
+
+int main()
+{
+    long id = id0.__get();
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+}
diff --git a/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp b/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locales/locale/nothing_to_do.pass.cpp b/test/localization/locales/locale/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locales/locale/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/locales/nothing_to_do.pass.cpp b/test/localization/locales/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/localization.general/nothing_to_do.pass.cpp b/test/localization/localization.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/localization/localization.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/localization/version.pass.cpp b/test/localization/version.pass.cpp
new file mode 100644
index 0000000..2618306
--- /dev/null
+++ b/test/localization/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+#include <locale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/nothing_to_do.pass.cpp b/test/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..8abaaa8
--- /dev/null
+++ b/test/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- C++ -*-
+//===-------------------------- algorithm ---------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/c.math/cmath.pass.cpp b/test/numerics/c.math/cmath.pass.cpp
new file mode 100644
index 0000000..f8e488f
--- /dev/null
+++ b/test/numerics/c.math/cmath.pass.cpp
@@ -0,0 +1,1337 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+void test_abs()
+{
+    static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::abs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long double)0)), long double>::value), "");
+    assert(std::abs(-1.) == 1);
+}
+
+void test_acos()
+{
+    static_assert((std::is_same<decltype(std::acos((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acos((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::acosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acosl(0)), long double>::value), "");
+    assert(std::acos(1) == 0);
+}
+
+void test_asin()
+{
+    static_assert((std::is_same<decltype(std::asin((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asin((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::asinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinl(0)), long double>::value), "");
+    assert(std::asin(0) == 0);
+}
+
+void test_atan()
+{
+    static_assert((std::is_same<decltype(std::atan((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanl(0)), long double>::value), "");
+    assert(std::atan(0) == 0);
+}
+
+void test_atan2()
+{
+    static_assert((std::is_same<decltype(std::atan2((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2f(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan2l(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (int)0)), double>::value), "");
+    assert(std::atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+    static_assert((std::is_same<decltype(std::ceil((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::ceilf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ceill(0)), long double>::value), "");
+    assert(std::ceil(0) == 0);
+}
+
+void test_cos()
+{
+    static_assert((std::is_same<decltype(std::cos((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cos((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::cosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cosl(0)), long double>::value), "");
+    assert(std::cos(0) == 1);
+}
+
+void test_cosh()
+{
+    static_assert((std::is_same<decltype(std::cosh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::coshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::coshl(0)), long double>::value), "");
+    assert(std::cosh(0) == 1);
+}
+
+void test_exp()
+{
+    static_assert((std::is_same<decltype(std::exp((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::expf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expl(0)), long double>::value), "");
+    assert(std::exp(0) == 1);
+}
+
+void test_fabs()
+{
+    static_assert((std::is_same<decltype(std::fabs((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fabsf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fabsl(0)), long double>::value), "");
+    assert(std::fabs(-1) == 1);
+}
+
+void test_floor()
+{
+    static_assert((std::is_same<decltype(std::floor((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::floor((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::floorf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::floorl(0)), long double>::value), "");
+    assert(std::floor(1) == 1);
+}
+
+void test_fmod()
+{
+    static_assert((std::is_same<decltype(std::fmod((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmodf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmodl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (int)0)), double>::value), "");
+    assert(std::fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+    int ip;
+    static_assert((std::is_same<decltype(std::frexp((float)0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((bool)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned short)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::frexpf(0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::frexpl(0, &ip)), long double>::value), "");
+    assert(std::frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+    int ip = 1;
+    static_assert((std::is_same<decltype(std::ldexp((float)0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((bool)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned short)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((int)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned int)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned long long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((double)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long double)0, ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexpf(0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ldexpl(0, ip)), long double>::value), "");
+    assert(std::ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+    static_assert((std::is_same<decltype(std::log((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::logf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logl(0)), long double>::value), "");
+    assert(std::log(1) == 0);
+}
+
+void test_log10()
+{
+    static_assert((std::is_same<decltype(std::log10((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log10((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log10f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log10l(0)), long double>::value), "");
+    assert(std::log10(1) == 0);
+}
+
+void test_modf()
+{
+    static_assert((std::is_same<decltype(std::modf((float)0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::modf((double)0, (double*)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::modf((long double)0, (long double*)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::modff(0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::modfl(0, (long double*)0)), long double>::value), "");
+    double i;
+    assert(std::modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+    static_assert((std::is_same<decltype(std::pow((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::pow((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::powf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::powl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (int)0)), double>::value), "");
+    assert(std::pow(1,1) == 1);
+}
+
+void test_sin()
+{
+    static_assert((std::is_same<decltype(std::sin((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sin((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinl(0)), long double>::value), "");
+    assert(std::sin(0) == 0);
+}
+
+void test_sinh()
+{
+    static_assert((std::is_same<decltype(std::sinh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinhl(0)), long double>::value), "");
+    assert(std::sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+    static_assert((std::is_same<decltype(std::sqrt((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sqrtl(0)), long double>::value), "");
+    assert(std::sqrt(4) == 2);
+}
+
+void test_tan()
+{
+    static_assert((std::is_same<decltype(std::tan((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tan((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanl(0)), long double>::value), "");
+    assert(std::tan(0) == 0);
+}
+
+void test_tanh()
+{
+    static_assert((std::is_same<decltype(std::tanh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanhl(0)), long double>::value), "");
+    assert(std::tanh(0) == 0);
+}
+
+void test_signbit()
+{
+#ifdef signbit
+#error signbit defined
+#endif
+    static_assert((std::is_same<decltype(std::signbit((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::signbit((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::signbit((long double)0)), bool>::value), "");
+    assert(std::signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+#ifdef fpclassify
+#error fpclassify defined
+#endif
+    static_assert((std::is_same<decltype(std::fpclassify((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fpclassify((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fpclassify((long double)0)), int>::value), "");
+    assert(std::fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+#ifdef isfinite
+#error isfinite defined
+#endif
+    static_assert((std::is_same<decltype(std::isfinite((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isfinite((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isfinite((long double)0)), bool>::value), "");
+    assert(std::isfinite(-1.0) == true);
+}
+
+void test_isinf()
+{
+#ifdef isinf
+#error isinf defined
+#endif
+    static_assert((std::is_same<decltype(std::isinf((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isinf((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isinf((long double)0)), bool>::value), "");
+    assert(std::isinf(-1.0) == false);
+}
+
+void test_isnan()
+{
+#ifdef isnan
+#error isnan defined
+#endif
+    static_assert((std::is_same<decltype(std::isnan((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnan((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnan((long double)0)), bool>::value), "");
+    assert(std::isnan(-1.0) == false);
+}
+
+void test_isnormal()
+{
+#ifdef isnormal
+#error isnormal defined
+#endif
+    static_assert((std::is_same<decltype(std::isnormal((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnormal((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnormal((long double)0)), bool>::value), "");
+    assert(std::isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+#ifdef isgreater
+#error isgreater defined
+#endif
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+#ifdef isgreaterequal
+#error isgreaterequal defined
+#endif
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+#ifdef isless
+#error isless defined
+#endif
+    static_assert((std::is_same<decltype(std::isless((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+#ifdef islessequal
+#error islessequal defined
+#endif
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (long double)0)), bool>::value), "");
+    assert(std::islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+#ifdef islessgreater
+#error islessgreater defined
+#endif
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(std::islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+#ifdef isunordered
+#error isunordered defined
+#endif
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+    static_assert((std::is_same<decltype(std::acosh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::acoshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acoshl(0)), long double>::value), "");
+    assert(std::acosh(1) == 0);
+}
+
+void test_asinh()
+{
+    static_assert((std::is_same<decltype(std::asinh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::asinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinhl(0)), long double>::value), "");
+    assert(std::asinh(0) == 0);
+}
+
+void test_atanh()
+{
+    static_assert((std::is_same<decltype(std::atanh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanhl(0)), long double>::value), "");
+    assert(std::atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+    static_assert((std::is_same<decltype(std::cbrt((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cbrtl(0)), long double>::value), "");
+    assert(std::cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+    static_assert((std::is_same<decltype(std::copysign((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysignf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::copysignl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (int)0)), double>::value), "");
+    assert(std::copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+    static_assert((std::is_same<decltype(std::erf((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erf((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::erff(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfl(0)), long double>::value), "");
+    assert(std::erf(0) == 0);
+}
+
+void test_erfc()
+{
+    static_assert((std::is_same<decltype(std::erfc((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::erfcf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfcl(0)), long double>::value), "");
+    assert(std::erfc(0) == 1);
+}
+
+void test_exp2()
+{
+    static_assert((std::is_same<decltype(std::exp2((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp2l(0)), long double>::value), "");
+    assert(std::exp2(1) == 2);
+}
+
+void test_expm1()
+{
+    static_assert((std::is_same<decltype(std::expm1((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expm1l(0)), long double>::value), "");
+    assert(std::expm1(0) == 0);
+}
+
+void test_fdim()
+{
+    static_assert((std::is_same<decltype(std::fdim((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdimf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fdiml(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (int)0)), double>::value), "");
+    assert(std::fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+    static_assert((std::is_same<decltype(std::fma((bool)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (int)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (long)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (float)0)), float>::value), "");
+
+    static_assert((std::is_same<decltype(std::fma((bool)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (int)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (long)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0,  (double)0)), double>::value), "");
+
+    static_assert((std::is_same<decltype(std::fma((bool)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (unsigned long long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (float)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (long double)0)), long double>::value), "");
+
+    static_assert((std::is_same<decltype(std::fmaf(0,0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmal(0,0,0)), long double>::value), "");
+    assert(std::fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+    static_assert((std::is_same<decltype(std::fmax((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmaxf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmaxl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (int)0)), double>::value), "");
+    assert(std::fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+    static_assert((std::is_same<decltype(std::fmin((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fminf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fminl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (int)0)), double>::value), "");
+    assert(std::fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+    static_assert((std::is_same<decltype(std::hypot((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypotf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::hypotl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (int)0)), double>::value), "");
+    assert(std::hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+    static_assert((std::is_same<decltype(std::ilogb((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((bool)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned short)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((int)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned int)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned long long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogbf(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogbl(0)), int>::value), "");
+    assert(std::ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+    static_assert((std::is_same<decltype(std::lgamma((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::lgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::lgammal(0)), long double>::value), "");
+    assert(std::lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+    static_assert((std::is_same<decltype(std::llrint((float)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((bool)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned short)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrintf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrintl(0)), long long>::value), "");
+    assert(std::llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+    static_assert((std::is_same<decltype(std::llround((float)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((bool)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned short)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llroundf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llroundl(0)), long long>::value), "");
+    assert(std::llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+    static_assert((std::is_same<decltype(std::log1p((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log1pf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log1pl(0)), long double>::value), "");
+    assert(std::log1p(0) == 0);
+}
+
+void test_log2()
+{
+    static_assert((std::is_same<decltype(std::log2((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log2((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log2l(0)), long double>::value), "");
+    assert(std::log2(1) == 0);
+}
+
+void test_logb()
+{
+    static_assert((std::is_same<decltype(std::logb((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logb((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::logbf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logbl(0)), long double>::value), "");
+    assert(std::logb(1) == 0);
+}
+
+void test_lrint()
+{
+    static_assert((std::is_same<decltype(std::lrint((float)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((bool)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned short)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrintf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrintl(0)), long>::value), "");
+    assert(std::lrint(1) == 1L);
+}
+
+void test_lround()
+{
+    static_assert((std::is_same<decltype(std::lround((float)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((bool)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned short)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lroundf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lroundl(0)), long>::value), "");
+    assert(std::lround(1) == 1L);
+}
+
+void test_nan()
+{
+    static_assert((std::is_same<decltype(std::nan("")), double>::value), "");
+    static_assert((std::is_same<decltype(std::nanf("")), float>::value), "");
+    static_assert((std::is_same<decltype(std::nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+    static_assert((std::is_same<decltype(std::nearbyint((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyintl(0)), long double>::value), "");
+    assert(std::nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafterf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nextafterl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (int)0)), double>::value), "");
+    assert(std::nextafter(0,1) == 0x1p-1074);
+}
+
+void test_nexttoward()
+{
+    static_assert((std::is_same<decltype(std::nexttoward((float)0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((bool)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned short)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((int)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned int)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned long long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((double)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttowardf(0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nexttowardl(0, (long double)0)), long double>::value), "");
+    assert(std::nexttoward(0, 1) == 0x1p-1074);
+}
+
+void test_remainder()
+{
+    static_assert((std::is_same<decltype(std::remainder((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainderf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remainderl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (int)0)), double>::value), "");
+    assert(std::remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+    int ip;
+    static_assert((std::is_same<decltype(std::remquo((float)0, (float)0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((bool)0, (float)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((unsigned short)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (unsigned int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((long double)0, (unsigned long)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (unsigned long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((long double)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquof(0,0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remquol(0,0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (int)0, &ip)), double>::value), "");
+    assert(std::remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+    static_assert((std::is_same<decltype(std::rint((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::rint((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::rintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::rintl(0)), long double>::value), "");
+    assert(std::rint(1) == 1);
+}
+
+void test_round()
+{
+    static_assert((std::is_same<decltype(std::round((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::round((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::roundf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::roundl(0)), long double>::value), "");
+    assert(std::round(1) == 1);
+}
+
+void test_scalbln()
+{
+    static_assert((std::is_same<decltype(std::scalbln((float)0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((bool)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned short)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((int)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned int)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned long long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long double)0, (long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::scalblnf(0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalblnl(0, (long)0)), long double>::value), "");
+    assert(std::scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+    static_assert((std::is_same<decltype(std::scalbn((float)0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((bool)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned short)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((int)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned int)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned long long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((double)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long double)0, (int)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbnf(0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbnl(0, (int)0)), long double>::value), "");
+    assert(std::scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+    static_assert((std::is_same<decltype(std::tgamma((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tgammal(0)), long double>::value), "");
+    assert(std::tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+    static_assert((std::is_same<decltype(std::trunc((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::truncf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::truncl(0)), long double>::value), "");
+    assert(std::trunc(1) == 1);
+}
+
+int main()
+{
+    test_acos();
+    test_asin();
+    test_atan();
+    test_atan2();
+    test_ceil();
+    test_cos();
+    test_cosh();
+    test_exp();
+    test_fabs();
+    test_floor();
+    test_fmod();
+    test_frexp();
+    test_ldexp();
+    test_log();
+    test_log10();
+    test_modf();
+    test_pow();
+    test_sin();
+    test_sinh();
+    test_sqrt();
+    test_tan();
+    test_tanh();
+    test_signbit();
+    test_fpclassify();
+    test_isfinite();
+    test_isinf();
+    test_isnan();
+    test_isnormal();
+    test_isgreater();
+    test_isgreaterequal();
+    test_isless();
+    test_islessequal();
+    test_islessgreater();
+    test_isunordered();
+    test_acosh();
+    test_asinh();
+    test_atanh();
+    test_cbrt();
+    test_copysign();
+    test_erf();
+    test_erfc();
+    test_exp2();
+    test_expm1();
+    test_fdim();
+    test_fma();
+    test_fmax();
+    test_fmin();
+    test_hypot();
+    test_ilogb();
+    test_lgamma();
+    test_llrint();
+    test_llround();
+    test_log1p();
+    test_log2();
+    test_logb();
+    test_lrint();
+    test_lround();
+    test_nan();
+    test_nearbyint();
+    test_nextafter();
+    test_nexttoward();
+    test_remainder();
+    test_remquo();
+    test_rint();
+    test_round();
+    test_scalbln();
+    test_scalbn();
+    test_tgamma();
+    test_trunc();
+}
diff --git a/test/numerics/c.math/ctgmath.pass.cpp b/test/numerics/c.math/ctgmath.pass.cpp
new file mode 100644
index 0000000..8cd7d3f
--- /dev/null
+++ b/test/numerics/c.math/ctgmath.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctgmath>
+
+#include <ctgmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> cd;
+    double x = std::sin(0);
+}
diff --git a/test/numerics/c.math/tgmath_h.pass.cpp b/test/numerics/c.math/tgmath_h.pass.cpp
new file mode 100644
index 0000000..6a1c204
--- /dev/null
+++ b/test/numerics/c.math/tgmath_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/c.math/version_cmath.pass.cpp b/test/numerics/c.math/version_cmath.pass.cpp
new file mode 100644
index 0000000..ea26224
--- /dev/null
+++ b/test/numerics/c.math/version_cmath.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+#include <cmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
new file mode 100644
index 0000000..c276023
--- /dev/null
+++ b/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfenv>
+
+#include <cfenv>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+    std::fenv_t fenv = {0};
+    std::fexcept_t fex = 0;
+    static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/test/numerics/cfenv/version.pass.cpp b/test/numerics/cfenv/version.pass.cpp
new file mode 100644
index 0000000..f90837f
--- /dev/null
+++ b/test/numerics/cfenv/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfenv>
+
+#include <cfenv>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/complex.number/cases.h b/test/numerics/complex.number/cases.h
new file mode 100644
index 0000000..b0b1805
--- /dev/null
+++ b/test/numerics/complex.number/cases.h
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// test cases
+
+#ifndef CASES_H
+#define CASES_H
+
+#include <complex>
+#include <cassert>
+
+std::complex<double> x[] =
+{
+    std::complex<double>( 1.e-6,  1.e-6),
+    std::complex<double>(-1.e-6,  1.e-6),
+    std::complex<double>(-1.e-6, -1.e-6),
+    std::complex<double>( 1.e-6, -1.e-6),
+
+    std::complex<double>( 1.e+6,  1.e-6),
+    std::complex<double>(-1.e+6,  1.e-6),
+    std::complex<double>(-1.e+6, -1.e-6),
+    std::complex<double>( 1.e+6, -1.e-6),
+
+    std::complex<double>( 1.e-6,  1.e+6),
+    std::complex<double>(-1.e-6,  1.e+6),
+    std::complex<double>(-1.e-6, -1.e+6),
+    std::complex<double>( 1.e-6, -1.e+6),
+
+    std::complex<double>( 1.e+6,  1.e+6),
+    std::complex<double>(-1.e+6,  1.e+6),
+    std::complex<double>(-1.e+6, -1.e+6),
+    std::complex<double>( 1.e+6, -1.e+6),
+
+    std::complex<double>(NAN, NAN),
+    std::complex<double>(-INFINITY, NAN),
+    std::complex<double>(-2, NAN),
+    std::complex<double>(-1, NAN),
+    std::complex<double>(-0.5, NAN),
+    std::complex<double>(-0., NAN),
+    std::complex<double>(+0., NAN),
+    std::complex<double>(0.5, NAN),
+    std::complex<double>(1, NAN),
+    std::complex<double>(2, NAN),
+    std::complex<double>(INFINITY, NAN),
+
+    std::complex<double>(NAN, -INFINITY),
+    std::complex<double>(-INFINITY, -INFINITY),
+    std::complex<double>(-2, -INFINITY),
+    std::complex<double>(-1, -INFINITY),
+    std::complex<double>(-0.5, -INFINITY),
+    std::complex<double>(-0., -INFINITY),
+    std::complex<double>(+0., -INFINITY),
+    std::complex<double>(0.5, -INFINITY),
+    std::complex<double>(1, -INFINITY),
+    std::complex<double>(2, -INFINITY),
+    std::complex<double>(INFINITY, -INFINITY),
+
+    std::complex<double>(NAN, -2),
+    std::complex<double>(-INFINITY, -2),
+    std::complex<double>(-2, -2),
+    std::complex<double>(-1, -2),
+    std::complex<double>(-0.5, -2),
+    std::complex<double>(-0., -2),
+    std::complex<double>(+0., -2),
+    std::complex<double>(0.5, -2),
+    std::complex<double>(1, -2),
+    std::complex<double>(2, -2),
+    std::complex<double>(INFINITY, -2),
+
+    std::complex<double>(NAN, -1),
+    std::complex<double>(-INFINITY, -1),
+    std::complex<double>(-2, -1),
+    std::complex<double>(-1, -1),
+    std::complex<double>(-0.5, -1),
+    std::complex<double>(-0., -1),
+    std::complex<double>(+0., -1),
+    std::complex<double>(0.5, -1),
+    std::complex<double>(1, -1),
+    std::complex<double>(2, -1),
+    std::complex<double>(INFINITY, -1),
+
+    std::complex<double>(NAN, -0.5),
+    std::complex<double>(-INFINITY, -0.5),
+    std::complex<double>(-2, -0.5),
+    std::complex<double>(-1, -0.5),
+    std::complex<double>(-0.5, -0.5),
+    std::complex<double>(-0., -0.5),
+    std::complex<double>(+0., -0.5),
+    std::complex<double>(0.5, -0.5),
+    std::complex<double>(1, -0.5),
+    std::complex<double>(2, -0.5),
+    std::complex<double>(INFINITY, -0.5),
+
+    std::complex<double>(NAN, -0.),
+    std::complex<double>(-INFINITY, -0.),
+    std::complex<double>(-2, -0.),
+    std::complex<double>(-1, -0.),
+    std::complex<double>(-0.5, -0.),
+    std::complex<double>(-0., -0.),
+    std::complex<double>(+0., -0.),
+    std::complex<double>(0.5, -0.),
+    std::complex<double>(1, -0.),
+    std::complex<double>(2, -0.),
+    std::complex<double>(INFINITY, -0.),
+
+    std::complex<double>(NAN, +0.),
+    std::complex<double>(-INFINITY, +0.),
+    std::complex<double>(-2, +0.),
+    std::complex<double>(-1, +0.),
+    std::complex<double>(-0.5, +0.),
+    std::complex<double>(-0., +0.),
+    std::complex<double>(+0., +0.),
+    std::complex<double>(0.5, +0.),
+    std::complex<double>(1, +0.),
+    std::complex<double>(2, +0.),
+    std::complex<double>(INFINITY, +0.),
+
+    std::complex<double>(NAN, 0.5),
+    std::complex<double>(-INFINITY, 0.5),
+    std::complex<double>(-2, 0.5),
+    std::complex<double>(-1, 0.5),
+    std::complex<double>(-0.5, 0.5),
+    std::complex<double>(-0., 0.5),
+    std::complex<double>(+0., 0.5),
+    std::complex<double>(0.5, 0.5),
+    std::complex<double>(1, 0.5),
+    std::complex<double>(2, 0.5),
+    std::complex<double>(INFINITY, 0.5),
+
+    std::complex<double>(NAN, 1),
+    std::complex<double>(-INFINITY, 1),
+    std::complex<double>(-2, 1),
+    std::complex<double>(-1, 1),
+    std::complex<double>(-0.5, 1),
+    std::complex<double>(-0., 1),
+    std::complex<double>(+0., 1),
+    std::complex<double>(0.5, 1),
+    std::complex<double>(1, 1),
+    std::complex<double>(2, 1),
+    std::complex<double>(INFINITY, 1),
+
+    std::complex<double>(NAN, 2),
+    std::complex<double>(-INFINITY, 2),
+    std::complex<double>(-2, 2),
+    std::complex<double>(-1, 2),
+    std::complex<double>(-0.5, 2),
+    std::complex<double>(-0., 2),
+    std::complex<double>(+0., 2),
+    std::complex<double>(0.5, 2),
+    std::complex<double>(1, 2),
+    std::complex<double>(2, 2),
+    std::complex<double>(INFINITY, 2),
+
+    std::complex<double>(NAN, INFINITY),
+    std::complex<double>(-INFINITY, INFINITY),
+    std::complex<double>(-2, INFINITY),
+    std::complex<double>(-1, INFINITY),
+    std::complex<double>(-0.5, INFINITY),
+    std::complex<double>(-0., INFINITY),
+    std::complex<double>(+0., INFINITY),
+    std::complex<double>(0.5, INFINITY),
+    std::complex<double>(1, INFINITY),
+    std::complex<double>(2, INFINITY),
+    std::complex<double>(INFINITY, INFINITY)
+};
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+template <class T>
+int
+classify(const std::complex<T>& x)
+{
+    if (x == std::complex<T>())
+        return zero;
+    if (std::isinf(x.real()) || std::isinf(x.imag()))
+        return inf;
+    if (std::isnan(x.real()) && std::isnan(x.imag()))
+        return NaN;
+    if (std::isnan(x.real()))
+    {
+        if (x.imag() == T(0))
+            return NaN;
+        return non_zero_nan;
+    }
+    if (std::isnan(x.imag()))
+    {
+        if (x.real() == T(0))
+            return NaN;
+        return non_zero_nan;
+    }
+    return non_zero;
+}
+
+inline
+int
+classify(double x)
+{
+    if (x == 0)
+        return zero;
+    if (std::isinf(x))
+        return inf;
+    if (std::isnan(x))
+        return NaN;
+    return non_zero;
+}
+
+void is_about(float x, float y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-6);
+}
+
+void is_about(double x, double y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+void is_about(long double x, long double y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+#endif
diff --git a/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp
new file mode 100644
index 0000000..06d031b
--- /dev/null
+++ b/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ccomplex>
+
+
+#include <ccomplex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> d;
+}
diff --git a/test/numerics/complex.number/cmplx.over/arg.pass.cpp b/test/numerics/complex.number/cmplx.over/arg.pass.cpp
new file mode 100644
index 0000000..a28515d
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/arg.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   arg(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
+    assert(std::arg(x) == arg(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
+    assert(std::arg(x) == arg(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/conj.pass.cpp b/test/numerics/complex.number/cmplx.over/conj.pass.cpp
new file mode 100644
index 0000000..69e6022
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/conj.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>      complex<T>  conj(const complex<T>&);
+//                        long double conj(long double);
+//                        double      conj(double);
+// template<Integral T>   double      conj(T);
+//                        float       conj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), double>::value), "");
+    assert(std::conj(x) == conj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), T>::value), "");
+    assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+                                  !std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+    assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/imag.pass.cpp b/test/numerics/complex.number/cmplx.over/imag.pass.cpp
new file mode 100644
index 0000000..62e9451
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/imag.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   imag(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::imag(x)), double>::value), "");
+    assert(std::imag(x) == 0);
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::imag(x)), T>::value), "");
+    assert(std::imag(x) == 0);
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/norm.pass.cpp b/test/numerics/complex.number/cmplx.over/norm.pass.cpp
new file mode 100644
index 0000000..cbadb8d
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/norm.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   norm(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::norm(x)), double>::value), "");
+    assert(std::norm(x) == norm(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::norm(x)), T>::value), "");
+    assert(std::norm(x) == norm(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/pow.pass.cpp b/test/numerics/complex.number/cmplx.over/pow.pass.cpp
new file mode 100644
index 0000000..78b9e36
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/pow.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const T& x, const complex<U>& y);
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const complex<T>& x, const U& y);
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const complex<T>& x, const complex<U>& y);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+double
+promote(T, typename std::enable_if<std::is_integral<T>::value>::type* = 0);
+
+float promote(float);
+double promote(double);
+long double promote(long double);
+
+template <class T, class U>
+void
+test(T x, const std::complex<U>& y)
+{
+    typedef decltype(promote(x)+promote(real(y))) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x, 0), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, U y)
+{
+    typedef decltype(promote(real(x))+promote(y)) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y, 0)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, const std::complex<U>& y)
+{
+    typedef decltype(promote(real(x))+promote(real(y))) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+    test(T(3), std::complex<U>(4, 5));
+    test(std::complex<U>(3, 4), T(5));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+    test(T(3), std::complex<U>(4, 5));
+    test(std::complex<T>(3, 4), U(5));
+    test(std::complex<T>(3, 4), std::complex<U>(5, 6));
+}
+
+
+int main()
+{
+    test<int, float>();
+    test<int, double>();
+    test<int, long double>();
+
+    test<unsigned, float>();
+    test<unsigned, double>();
+    test<unsigned, long double>();
+
+    test<long long, float>();
+    test<long long, double>();
+    test<long long, long double>();
+
+    test<float, double>();
+    test<float, long double>();
+
+    test<double, float>();
+    test<double, long double>();
+
+    test<long double, float>();
+    test<long double, double>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/proj.pass.cpp b/test/numerics/complex.number/cmplx.over/proj.pass.cpp
new file mode 100644
index 0000000..d27511f
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/proj.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>    complex<T>  proj(const complex<T>&);
+//                      long double proj(long double);
+//                      double      proj(double);
+// template<Integral T> double      proj(T);
+//                      float       proj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), double>::value), "");
+    assert(std::proj(x) == proj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), T>::value), "");
+    assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+                                  !std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+    assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/cmplx.over/real.pass.cpp b/test/numerics/complex.number/cmplx.over/real.pass.cpp
new file mode 100644
index 0000000..c62cb4d
--- /dev/null
+++ b/test/numerics/complex.number/cmplx.over/real.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   real(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::real(x)), double>::value), "");
+    assert(std::real(x) == x);
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::real(x)), T>::value), "");
+    assert(std::real(x) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp b/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
new file mode 100644
index 0000000..0eaf9d6
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/assignment_complex.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator=(const complex&); 
+// template<class X> complex& operator= (const complex<X>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T, class X>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    std::complex<T> c2(1.5, 2.5);
+    c = c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    std::complex<X> c3(3.5, -4.5);
+    c = c3;
+    assert(c.real() == 3.5);
+    assert(c.imag() == -4.5);
+}
+
+int main()
+{
+    test<float, float>();
+    test<float, double>();
+    test<float, long double>();
+
+    test<double, float>();
+    test<double, double>();
+    test<double, long double>();
+
+    test<long double, float>();
+    test<long double, double>();
+    test<long double, long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp b/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
new file mode 100644
index 0000000..f051c49
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/assignment_scalar.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator= (const T&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c = 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c = -1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp b/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
new file mode 100644
index 0000000..253f0da
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(-4, 7.5);
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == -4);
+    assert(c.imag() == 7.5);
+    c /= c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c /= c2;
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp b/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
new file mode 100644
index 0000000..7083302
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c /= 0.5;
+    assert(c.real() == 2);
+    assert(c.imag() == 0);
+    c /= 0.5;
+    assert(c.real() == 4);
+    assert(c.imag() == 0);
+    c /= -0.5;
+    assert(c.real() == -8);
+    assert(c.imag() == 0);
+    c.imag(2);
+    c /= 0.5;
+    assert(c.real() == -16);
+    assert(c.imag() == 4);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp b/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
new file mode 100644
index 0000000..fdae56f
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c -= c2;
+    assert(c.real() == -1.5);
+    assert(c.imag() == -2.5);
+    c -= c2;
+    assert(c.real() == -3);
+    assert(c.imag() == -5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp b/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
new file mode 100644
index 0000000..a13064d
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c -= 1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+    c -= 1.5;
+    assert(c.real() == -3);
+    assert(c.imag() == 0);
+    c -= -1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp b/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
new file mode 100644
index 0000000..aa19f61
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c += c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c += c2;
+    assert(c.real() == 3);
+    assert(c.imag() == 5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp b/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
new file mode 100644
index 0000000..1a1b593
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c += 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c += 1.5;
+    assert(c.real() == 3);
+    assert(c.imag() == 0);
+    c += -1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp b/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
new file mode 100644
index 0000000..4fae671
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c *= c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c *= c2;
+    assert(c.real() == -4);
+    assert(c.imag() == 7.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp b/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
new file mode 100644
index 0000000..5e39d4b
--- /dev/null
+++ b/test/numerics/complex.number/complex.member.ops/times_equal_scalar.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c *= 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c *= 1.5;
+    assert(c.real() == 2.25);
+    assert(c.imag() == 0);
+    c *= -1.5;
+    assert(c.real() == -3.375);
+    assert(c.imag() == 0);
+    c.imag(2);
+    c *= 1.5;
+    assert(c.real() == -5.0625);
+    assert(c.imag() == 3);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.members/construct.pass.cpp b/test/numerics/complex.number/complex.members/construct.pass.cpp
new file mode 100644
index 0000000..6ec6258
--- /dev/null
+++ b/test/numerics/complex.number/complex.members/construct.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex(const T& re = T(), const T& im = T());
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+    const std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c = 7.5;
+    assert(c.real() == 7.5);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c(8.5);
+    assert(c.real() == 8.5);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c(10.5, -9.5);
+    assert(c.real() == 10.5);
+    assert(c.imag() == -9.5);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.members/real_imag.pass.cpp b/test/numerics/complex.number/complex.members/real_imag.pass.cpp
new file mode 100644
index 0000000..7f2ee32
--- /dev/null
+++ b/test/numerics/complex.number/complex.members/real_imag.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// void real(T val);
+// void imag(T val);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c.real(3.5);
+    assert(c.real() == 3.5);
+    assert(c.imag() == 0);
+    c.imag(4.5);
+    assert(c.real() == 3.5);
+    assert(c.imag() == 4.5);
+    c.real(-4.5);
+    assert(c.real() == -4.5);
+    assert(c.imag() == 4.5);
+    c.imag(-5.5);
+    assert(c.real() == -4.5);
+    assert(c.imag() == -5.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
new file mode 100644
index 0000000..99c5db2
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   complex<T>
+//   operator/(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(-4.0, 7.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(1.5, 2.5);
+    test(lhs, rhs, x);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = x[i] / x[j];
+            switch (classify(x[i]))
+            {
+            case zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == zero);
+                    break;
+                case inf:
+                    assert(classify(r) == zero);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == non_zero);
+                    break;
+                case inf:
+                    assert(classify(r) == zero);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case inf:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == inf);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case NaN:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero_nan:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
new file mode 100644
index 0000000..c95ee7d
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator/(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(-4.0, 7.5);
+    T rhs(2);
+    std::complex<T>   x(-2, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
new file mode 100644
index 0000000..59258b0
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   bool
+//   operator==(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    std::complex<T> rhs(1.5, -2.5);
+    test(lhs, rhs, false);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    test(lhs, rhs, true);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
new file mode 100644
index 0000000..9329d8d
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator==(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    T rhs(-2.5);
+    test(lhs, rhs, false);
+    }
+    {
+    std::complex<T> lhs(1.5,  0);
+    T rhs(-2.5);
+    test(lhs, rhs, false);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    test(lhs, rhs, false);
+    }
+    {
+    std::complex<T> lhs(1.5, 0);
+    T rhs(1.5);
+    test(lhs, rhs, true);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
new file mode 100644
index 0000000..fa0ec33
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   complex<T>
+//   operator-(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(-2.0, -2.0);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(5.0, -7.0);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
new file mode 100644
index 0000000..ebd2c9e
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(3.5);
+    std::complex<T>   x(-2.0, 2.5);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    T rhs(-3.5);
+    std::complex<T>   x(5.0, -2.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
new file mode 100644
index 0000000..fb89ec9
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   bool
+//   operator!=(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    std::complex<T> rhs(1.5, -2.5);
+    test(lhs, rhs, true);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    test(lhs, rhs, false);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
new file mode 100644
index 0000000..fd70688
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator!=(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    T rhs(-2.5);
+    test(lhs, rhs, true);
+    }
+    {
+    std::complex<T> lhs(1.5,  0);
+    T rhs(-2.5);
+    test(lhs, rhs, true);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    test(lhs, rhs, true);
+    }
+    {
+    std::complex<T> lhs(1.5, 0);
+    T rhs(1.5);
+    test(lhs, rhs, false);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
new file mode 100644
index 0000000..e9b5804
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   complex<T>
+//   operator+(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(5.0, 7.0);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(-2.0, 2.0);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
new file mode 100644
index 0000000..d7e0d31
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(3.5);
+    std::complex<T>   x(5.0, 2.5);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    T rhs(-3.5);
+    std::complex<T>   x(-2.0, -2.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
new file mode 100644
index 0000000..890ce05
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
@@ -0,0 +1,161 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   complex<T>
+//   operator*(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(-4.0, 7.5);
+    test(lhs, rhs, x);
+}
+
+// test edges
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = x[i] * x[j];
+            switch (classify(x[i]))
+            {
+            case zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == zero);
+                    break;
+                case non_zero:
+                    assert(classify(r) == zero);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == zero);
+                    break;
+                case non_zero:
+                    assert(classify(r) == non_zero);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case inf:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == inf);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == inf);
+                    break;
+                }
+                break;
+            case NaN:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero_nan:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp b/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
new file mode 100644
index 0000000..d8228c5
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator*(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    std::complex<T>   x(2.25, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
new file mode 100644
index 0000000..6c8d5ec
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator/(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    T lhs(-8.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(-1.5, 2.5);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
new file mode 100644
index 0000000..86b2f52
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator==(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  2.5);
+    test(lhs, rhs, false);
+    }
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  0);
+    test(lhs, rhs, false);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    test(lhs, rhs, false);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 0);
+    test(lhs, rhs, true);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
new file mode 100644
index 0000000..4958e41
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(-2.0, -4.5);
+    test(lhs, rhs, x);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(5.0, -4.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
new file mode 100644
index 0000000..a73f627
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator!=(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  2.5);
+    test(lhs, rhs, true);
+    }
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  0);
+    test(lhs, rhs, true);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    test(lhs, rhs, true);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 0);
+    test(lhs, rhs, false);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
new file mode 100644
index 0000000..a21ebc7
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(5.0, 4.5);
+    test(lhs, rhs, x);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(-2.0, 4.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp b/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
new file mode 100644
index 0000000..d3cbce8
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator*(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(2.25, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/stream_input.pass.cpp b/test/numerics/complex.number/complex.ops/stream_input.pass.cpp
new file mode 100644
index 0000000..6da9127
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/stream_input.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits> 
+//   basic_istream<charT, traits>& 
+//   operator>>(basic_istream<charT, traits>& is, complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream is("5");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.eof());
+    }
+    {
+        std::istringstream is(" 5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" 5, ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" , 5, ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("5.5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" ( 5.5 ) ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is("  5.5)");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is("(5.5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("(5.5,");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("( -5.5 , -6.5 )");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(-5.5, -6.5));
+        assert(is.eof());
+    }
+    {
+        std::istringstream is("(-5.5,-6.5)");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(-5.5, -6.5));
+        assert(is.eof());
+    }
+}
diff --git a/test/numerics/complex.number/complex.ops/stream_output.pass.cpp b/test/numerics/complex.number/complex.ops/stream_output.pass.cpp
new file mode 100644
index 0000000..a6ed552
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/stream_output.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits> 
+//   basic_ostream<charT, traits>& 
+//   operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::complex<double> c(1, 2);
+    std::ostringstream os;
+    os << c;
+    assert(os.str() == "(1,2)");
+}
diff --git a/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp b/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp
new file mode 100644
index 0000000..8104707
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/unary_minus.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const complex<T>& lhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(z.real() == 1.5);
+    assert(z.imag() == 2.5);
+    std::complex<T> c = -z;
+    assert(c.real() == -1.5);
+    assert(c.imag() == -2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp b/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp
new file mode 100644
index 0000000..d0ac984
--- /dev/null
+++ b/test/numerics/complex.number/complex.ops/unary_plus.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const complex<T>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(z.real() == 1.5);
+    assert(z.imag() == 2.5);
+    std::complex<T> c = +z;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp b/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
new file mode 100644
index 0000000..40169f3
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// { 
+// public: 
+//     constexpr complex(const complex<float>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp b/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
new file mode 100644
index 0000000..34e4728
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// { 
+// public: 
+//     constexpr complex(const complex<float>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp b/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
new file mode 100644
index 0000000..1c9e316
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<long double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp b/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
new file mode 100644
index 0000000..a4c30db
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<long double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp b/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
new file mode 100644
index 0000000..1caf694
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<float> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp b/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
new file mode 100644
index 0000000..7db9dfe
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<float> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp b/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
new file mode 100644
index 0000000..758ffef
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<long double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<float> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp b/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
new file mode 100644
index 0000000..109e68f
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// { 
+// public: 
+//     explicit constexpr complex(const complex<long double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<float> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp b/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
new file mode 100644
index 0000000..2c06041
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// { 
+// public: 
+//     constexpr complex(const complex<double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<long double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp b/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
new file mode 100644
index 0000000..579190e
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// { 
+// public: 
+//     constexpr complex(const complex<double>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<long double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp b/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
new file mode 100644
index 0000000..03dd952
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// { 
+// public: 
+//     constexpr complex(const complex<float>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<long double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp b/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
new file mode 100644
index 0000000..22af363
--- /dev/null
+++ b/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// { 
+// public: 
+//     constexpr complex(const complex<float>&); 
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<long double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp b/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp b/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp
new file mode 100644
index 0000000..2579459
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   acos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(acos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(INFINITY, 1), std::complex<T>(0, -INFINITY));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = acos(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            is_about(r.real(), pi/2);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            is_about(r.real(), pi/2);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), pi/2);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && x[i].real() != 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            is_about(r.real(), pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), 0.75 * pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), 0.25 * pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (!std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert( std::signbit(r.imag()));
+        }
+        else if (std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert( std::signbit(r.imag()));
+        }
+        else if (std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+        else if (!std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
new file mode 100644
index 0000000..46c1262
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   acosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(acosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(INFINITY, 1), std::complex<T>(INFINITY, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = acosh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(!std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (x[i].real() == 1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi);
+            else
+                is_about(r.imag(),  pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -0.75 * pi);
+            else
+                is_about(r.imag(),  0.75 * pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -0.25 * pi);
+            else
+                is_about(r.imag(),  0.25 * pi);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp b/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp
new file mode 100644
index 0000000..d667a73
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   asin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(asin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = asin(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            if (x[i].real() > 0)
+                is_about(r.real(),  pi/2);
+            else
+                is_about(r.real(), - pi/2);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            if (std::signbit(x[i].real()))
+                is_about(r.real(), -pi/4);
+            else
+                is_about(r.real(),  pi/4);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].real()) != std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
new file mode 100644
index 0000000..f5fc92f
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   asinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(asinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = asinh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/4);
+            else
+                is_about(r.imag(),  pi/4);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp
new file mode 100644
index 0000000..27a6b33
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   atan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(atan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = atan(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = atanh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
new file mode 100644
index 0000000..c432810
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   atanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(atanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = atanh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (abs(x[i].real()) == 1 && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (x[i].imag() > 0)
+                is_about(r.imag(),  pi/2);
+            else
+                is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp b/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp
new file mode 100644
index 0000000..4cbceb2
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   cos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(cos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = cos(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> z = cosh(t1);
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
new file mode 100644
index 0000000..9884fce
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   cosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(cosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = cosh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(!std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(cos(x[i].imag())));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].real() * sin(x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp b/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp
new file mode 100644
index 0000000..a0c4b80
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   exp(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(exp(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = exp(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 1.0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() != 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].imag()) && std::abs(x[i].imag()) <= 1)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/log.pass.cpp b/test/numerics/complex.number/complex.transcendentals/log.pass.cpp
new file mode 100644
index 0000000..b729db4
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/log.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   log(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(log(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = log(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            if (std::signbit(x[i].real()))
+            {
+                assert(std::isinf(r.real()));
+                assert(r.real() < 0);
+                if (std::signbit(x[i].imag()))
+                    is_about(r.imag(), -pi);
+                else
+                    is_about(r.imag(), pi);
+            }
+            else
+            {
+                assert(std::isinf(r.real()));
+                assert(r.real() < 0);
+                assert(r.imag() == 0);
+                assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+            }
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (x[i].imag() > 0)
+                is_about(r.imag(), pi/2);
+            else
+                is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()) && r.real() > 0);
+            if (r.imag() > 0)
+                is_about(r.imag(), pi);
+            else
+                is_about(r.imag(), -pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()) && r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (x[i].real() == 1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && x[i].imag() == 1)
+        {
+            assert(r.real() == 0);
+            is_about(r.imag(), pi/2);
+        }
+        else if (x[i].real() == -1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi);
+            else
+                is_about(r.imag(),  pi);
+        }
+        else if (x[i].real() == 0 && x[i].imag() == -1)
+        {
+            assert(r.real() == 0);
+            is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) < 1)
+        {
+            assert( std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) > 1)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp b/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp
new file mode 100644
index 0000000..228787d
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   log10(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(log10(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = log10(x[i]);
+        std::complex<double> z = log(x[i])/std::log(10);
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp b/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
new file mode 100644
index 0000000..5973691
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+//   complex<T>
+//   pow(const complex<T>& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const std::complex<T>& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(2, 3), std::complex<T>(2, 0), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(x[i], x[j]);
+            std::complex<double> z = exp(x[j] * log(x[i]));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+                assert(std::signbit(real(r)) == std::signbit(real(z)));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+                assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp b/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
new file mode 100644
index 0000000..288be67
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   pow(const complex<T>& x, const T& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const T& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(2, 3), T(2), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(x[i], real(x[j]));
+            std::complex<double> z = exp(std::complex<double>(real(x[j])) * log(x[i]));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp b/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
new file mode 100644
index 0000000..3aa7447
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   pow(const T& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& a, const std::complex<T>& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+    test(T(2), std::complex<T>(2), std::complex<T>(4));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(real(x[i]), x[j]);
+            std::complex<double> z = exp(x[j] * log(std::complex<double>(real(x[i]))));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp b/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp
new file mode 100644
index 0000000..4e6868c
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/sin.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(sin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sin(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = sinh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
new file mode 100644
index 0000000..093ba12
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(sinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sinh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(x[i].real() * cos(x[i].imag())));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(sin(x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp b/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
new file mode 100644
index 0000000..63eeb27
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sqrt(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    std::complex<T> a = sqrt(c);
+    is_about(real(a), real(x));
+    assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(64, 0), std::complex<T>(8, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sqrt(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && (std::isfinite(x[i].imag()) || std::isnan(x[i].imag())))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()));
+        }
+        else
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp
new file mode 100644
index 0000000..801339e
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/tan.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   tan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(tan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = tan(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = tanh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp b/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
new file mode 100644
index 0000000..36644fc
--- /dev/null
+++ b/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   tanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(tanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = tanh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(sin(2*x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/abs.pass.cpp b/test/numerics/complex.number/complex.value.ops/abs.pass.cpp
new file mode 100644
index 0000000..5f37f1e
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/abs.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   abs(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(3, 4);
+    assert(abs(z) == 5);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = abs(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+            assert(r == 0);
+            assert(!std::signbit(r));
+            break;
+        case non_zero:
+            assert(std::isfinite(r) && r > 0);
+            break;
+        case inf:
+            assert(std::isinf(r) && r > 0);
+            break;
+        case NaN:
+            assert(std::isnan(r));
+            break;
+        case non_zero_nan:
+            assert(std::isnan(r));
+            break;
+        }
+    }
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/arg.pass.cpp b/test/numerics/complex.number/complex.value.ops/arg.pass.cpp
new file mode 100644
index 0000000..826e764
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/arg.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   arg(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1, 0);
+    assert(arg(z) == 0);
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = arg(x[i]);
+        if (std::isnan(x[i].real()) || std::isnan(x[i].imag()))
+            assert(std::isnan(r));
+        else
+        {
+            switch (classify(x[i]))
+            {
+            case zero:
+                if (std::signbit(x[i].real()))
+                {
+                    if (std::signbit(x[i].imag()))
+                        is_about(r, -pi);
+                    else
+                        is_about(r, pi);
+                }
+                else
+                {
+                    assert(std::signbit(x[i].imag()) == std::signbit(r));
+                }
+                break;
+            case non_zero:
+                if (x[i].real() == 0)
+                {
+                    if (x[i].imag() < 0)
+                        is_about(r, -pi/2);
+                    else
+                        is_about(r, pi/2);
+                }
+                else if (x[i].imag() == 0)
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (std::signbit(x[i].imag()))
+                            is_about(r, -pi);
+                        else
+                            is_about(r, pi);
+                    }
+                    else
+                    {
+                        assert(r == 0);
+                        assert(std::signbit(x[i].imag()) == std::signbit(r));
+                    }
+                }
+                else if (x[i].imag() > 0)
+                    assert(r > 0);
+                else
+                    assert(r < 0);
+                break;
+            case inf:
+                if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (x[i].imag() > 0)
+                            is_about(r, 0.75 * pi);
+                        else
+                            is_about(r, -0.75 * pi);
+                    }
+                    else
+                    {
+                        if (x[i].imag() > 0)
+                            is_about(r, 0.25 * pi);
+                        else
+                            is_about(r, -0.25 * pi);
+                    }
+                }
+                else if (std::isinf(x[i].real()))
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (std::signbit(x[i].imag()))
+                            is_about(r, -pi);
+                        else
+                            is_about(r, pi);
+                    }
+                    else
+                    {
+                        assert(r == 0);
+                        assert(std::signbit(r) == std::signbit(x[i].imag()));
+                    }
+                }
+                else
+                {
+                    if (x[i].imag() < 0)
+                        is_about(r, -pi/2);
+                    else
+                        is_about(r, pi/2);
+                }
+                break;
+            }
+        }
+    }
+}
+
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/conj.pass.cpp b/test/numerics/complex.number/complex.value.ops/conj.pass.cpp
new file mode 100644
index 0000000..4b83b92
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/conj.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   conj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+    assert(conj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(1, 2), std::complex<T>(1, -2));
+    test(std::complex<T>(-1, 2), std::complex<T>(-1, -2));
+    test(std::complex<T>(1, -2), std::complex<T>(1, 2));
+    test(std::complex<T>(-1, -2), std::complex<T>(-1, 2));
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/imag.pass.cpp b/test/numerics/complex.number/complex.value.ops/imag.pass.cpp
new file mode 100644
index 0000000..a169895
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/imag.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   imag(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(imag(z) == 2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/norm.pass.cpp b/test/numerics/complex.number/complex.value.ops/norm.pass.cpp
new file mode 100644
index 0000000..0ab8f32
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/norm.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   norm(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(3, 4);
+    assert(norm(z) == 25);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = norm(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+            assert(r == 0);
+            assert(!std::signbit(r));
+            break;
+        case non_zero:
+            assert(std::isfinite(r) && r > 0);
+            break;
+        case inf:
+            assert(std::isinf(r) && r > 0);
+            break;
+        case NaN:
+            assert(std::isnan(r));
+            break;
+        case non_zero_nan:
+            assert(std::isnan(r));
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/polar.pass.cpp b/test/numerics/complex.number/complex.value.ops/polar.pass.cpp
new file mode 100644
index 0000000..4a39134
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/polar.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   polar(const T& rho, const T& theta = 0);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& rho, std::complex<T> x)
+{
+    assert(std::polar(rho) == x);
+}
+
+template <class T>
+void
+test(const T& rho, const T& theta, std::complex<T> x)
+{
+    assert(std::polar(rho, theta) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(T(0), std::complex<T>(0, 0));
+    test(T(1), std::complex<T>(1, 0));
+    test(T(100), std::complex<T>(100, 0));
+    test(T(0), T(0), std::complex<T>(0, 0));
+    test(T(1), T(0), std::complex<T>(1, 0));
+    test(T(100), T(0), std::complex<T>(100, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = real(x[i]);
+        double theta = imag(x[i]);
+        std::complex<double> z = std::polar(r, theta);
+        switch (classify(r))
+        {
+        case zero:
+            if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                assert(z == std::complex<double>());
+            }
+            break;
+        case non_zero:
+            if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                is_about(std::abs(z), r);
+            }
+            break;
+        case inf:
+            if (r < 0)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                assert(classify(z) == inf);
+                if (classify(theta) != NaN && classify(theta) != inf)
+                {
+                    assert(classify(real(z)) != NaN);
+                    assert(classify(imag(z)) != NaN);
+                }
+            }
+            break;
+        case NaN:
+        case non_zero_nan:
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/proj.pass.cpp b/test/numerics/complex.number/complex.value.ops/proj.pass.cpp
new file mode 100644
index 0000000..99d0ec0
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/proj.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   proj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+    assert(proj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(1, 2), std::complex<T>(1, 2));
+    test(std::complex<T>(-1, 2), std::complex<T>(-1, 2));
+    test(std::complex<T>(1, -2), std::complex<T>(1, -2));
+    test(std::complex<T>(-1, -2), std::complex<T>(-1, -2));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = proj(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+        case non_zero:
+            assert(r == x[i]);
+            assert(std::signbit(real(r)) == std::signbit(real(x[i])));
+            assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+            break;
+        case inf:
+            assert(std::isinf(real(r)) && real(r) > 0);
+            assert(imag(r) == 0);
+            assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+            break;
+        case NaN:
+        case non_zero_nan:
+            assert(classify(r) == classify(x[i]));
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/test/numerics/complex.number/complex.value.ops/real.pass.cpp b/test/numerics/complex.number/complex.value.ops/real.pass.cpp
new file mode 100644
index 0000000..f265153
--- /dev/null
+++ b/test/numerics/complex.number/complex.value.ops/real.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   real(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(real(z) == 1.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/complex/types.pass.cpp b/test/numerics/complex.number/complex/types.pass.cpp
new file mode 100644
index 0000000..0fee77e
--- /dev/null
+++ b/test/numerics/complex.number/complex/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> 
+// class complex
+// { 
+// public: 
+//   typedef T value_type; 
+//   ...
+// };
+
+#include <complex>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    typedef std::complex<T> C;
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/layout.pass.cpp b/test/numerics/complex.number/layout.pass.cpp
new file mode 100644
index 0000000..c0945a2
--- /dev/null
+++ b/test/numerics/complex.number/layout.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z;
+    T* a = (T*)&z;
+    assert(0 == z.real());
+    assert(0 == z.imag());
+    assert(a[0] == z.real());
+    assert(a[1] == z.imag());
+    a[0] = 5;
+    a[1] = 6;
+    assert(a[0] == z.real());
+    assert(a[1] == z.imag());
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/numerics/complex.number/version.pass.cpp b/test/numerics/complex.number/version.pass.cpp
new file mode 100644
index 0000000..e4c21b1
--- /dev/null
+++ b/test/numerics/complex.number/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/nothing_to_do.pass.cpp b/test/numerics/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp b/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp b/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
new file mode 100644
index 0000000..9be9f66
--- /dev/null
+++ b/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::gslice gs;
+    assert(gs.start() == 0);
+    assert(gs.size().size() == 0);
+    assert(gs.stride().size() == 0);
+}
diff --git a/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp b/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
new file mode 100644
index 0000000..4dff73d
--- /dev/null
+++ b/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice(size_t start, const valarray<size_t>& size,
+//                      const valarray<size_t>& stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::size_t a1[] = {1, 2, 3};
+    std::size_t a2[] = {4, 5, 6};
+    std::valarray<std::size_t> size(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<std::size_t> stride(a2, sizeof(a2)/sizeof(a2[0]));
+    std::gslice gs(7, size, stride);
+    assert(gs.start() == 7);
+    std::valarray<std::size_t> r = gs.size();
+    assert(r.size() == 3);
+    assert(r[0] == 1);
+    assert(r[1] == 2);
+    assert(r[2] == 3);
+    r = gs.stride();
+    assert(r.size() == 3);
+    assert(r[0] == 4);
+    assert(r[1] == 5);
+    assert(r[2] == 6);
+}
diff --git a/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp b/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp b/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp
new file mode 100644
index 0000000..6a3b331
--- /dev/null
+++ b/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::slice s;
+    assert(s.start() == 0);
+    assert(s.size() == 0);
+    assert(s.stride() == 0);
+}
diff --git a/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp b/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
new file mode 100644
index 0000000..911d760
--- /dev/null
+++ b/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice(size_t start, size_t size, size_t stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::slice s(1, 3, 2);
+    assert(s.start() == 1);
+    assert(s.size() == 3);
+    assert(s.stride() == 2);
+}
diff --git a/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp b/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp b/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/template.gslice.array/default.fail.cpp b/test/numerics/numarray/template.gslice.array/default.fail.cpp
new file mode 100644
index 0000000..8c9d014
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// gslice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::gslice_array<int> gs;
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
new file mode 100644
index 0000000..98ad611
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// const gslice_array& operator=(const gslice_array& ga) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+                -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+                -36, -37};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))]
+        = v2[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                            strides(st, sizeof(st)/sizeof(st[0])))];
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] == -5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] == -8);
+    assert(v1[ 9] == -9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -11);
+    assert(v1[12] == -12);
+    assert(v1[13] == -13);
+    assert(v1[14] == 14);
+    assert(v1[15] == -15);
+    assert(v1[16] == -16);
+    assert(v1[17] == -17);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -22);
+    assert(v1[23] == -23);
+    assert(v1[24] == -24);
+    assert(v1[25] == 25);
+    assert(v1[26] == -26);
+    assert(v1[27] == -27);
+    assert(v1[28] == -28);
+    assert(v1[29] == 29);
+    assert(v1[30] == -30);
+    assert(v1[31] == -31);
+    assert(v1[32] == -32);
+    assert(v1[33] == 33);
+    assert(v1[34] == -34);
+    assert(v1[35] == -35);
+    assert(v1[36] == -36);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..f5f837c
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..ece3f94
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] += v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  3);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  4);
+    assert(v1[ 9] ==  4);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] ==  5);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  6);
+    assert(v1[16] ==  6);
+    assert(v1[17] ==  6);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 10);
+    assert(v1[23] == 10);
+    assert(v1[24] == 10);
+    assert(v1[25] == 25);
+    assert(v1[26] == 11);
+    assert(v1[27] == 11);
+    assert(v1[28] == 11);
+    assert(v1[29] == 29);
+    assert(v1[30] == 12);
+    assert(v1[31] == 12);
+    assert(v1[32] == 12);
+    assert(v1[33] == 33);
+    assert(v1[34] == 13);
+    assert(v1[35] == 13);
+    assert(v1[36] == 13);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..732fd92
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] &= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  3);
+    assert(v1[12] ==  8);
+    assert(v1[13] ==  9);
+    assert(v1[14] == 14);
+    assert(v1[15] == 10);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  4);
+    assert(v1[23] ==  6);
+    assert(v1[24] ==  8);
+    assert(v1[25] == 25);
+    assert(v1[26] == 16);
+    assert(v1[27] == 17);
+    assert(v1[28] == 16);
+    assert(v1[29] == 29);
+    assert(v1[30] == 18);
+    assert(v1[31] == 20);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  2);
+    assert(v1[35] ==  3);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..d33e0e1
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] /= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  1);
+    assert(v1[ 9] ==  1);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] ==  1);
+    assert(v1[13] ==  1);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  1);
+    assert(v1[16] ==  1);
+    assert(v1[17] ==  1);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  1);
+    assert(v1[23] ==  1);
+    assert(v1[24] ==  1);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  1);
+    assert(v1[27] ==  1);
+    assert(v1[28] ==  1);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  1);
+    assert(v1[31] ==  1);
+    assert(v1[32] ==  1);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  1);
+    assert(v1[35] ==  1);
+    assert(v1[36] ==  1);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..6bb85a5
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] %= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..a760c87
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] *= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  8);
+    assert(v1[ 5] == 15);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] == 40);
+    assert(v1[ 9] == 54);
+    assert(v1[10] == 10);
+    assert(v1[11] == 77);
+    assert(v1[12] == 96);
+    assert(v1[13] == 117);
+    assert(v1[14] == 14);
+    assert(v1[15] == 150);
+    assert(v1[16] == 176);
+    assert(v1[17] == 204);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 286);
+    assert(v1[23] == 322);
+    assert(v1[24] == 360);
+    assert(v1[25] == 25);
+    assert(v1[26] == 416);
+    assert(v1[27] == 459);
+    assert(v1[28] == 504);
+    assert(v1[29] == 29);
+    assert(v1[30] == 570);
+    assert(v1[31] == 620);
+    assert(v1[32] == 672);
+    assert(v1[33] == 33);
+    assert(v1[34] == 748);
+    assert(v1[35] == 805);
+    assert(v1[36] == 864);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..5e53b8f
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] |= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  7);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 31);
+    assert(v1[23] == 31);
+    assert(v1[24] == 31);
+    assert(v1[25] == 25);
+    assert(v1[26] == 26);
+    assert(v1[27] == 27);
+    assert(v1[28] == 30);
+    assert(v1[29] == 29);
+    assert(v1[30] == 31);
+    assert(v1[31] == 31);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 54);
+    assert(v1[35] == 55);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..1fb32ba
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator<<= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] <<= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] == 40);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] == 256);
+    assert(v1[ 9] == 576);
+    assert(v1[10] == 10);
+    assert(v1[11] == 1408);
+    assert(v1[12] == 3072);
+    assert(v1[13] == 6656);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15360);
+    assert(v1[16] == 32768);
+    assert(v1[17] == 69632);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 180224);
+    assert(v1[23] == 376832);
+    assert(v1[24] == 786432);
+    assert(v1[25] == 25);
+    assert(v1[26] == 1703936);
+    assert(v1[27] == 3538944);
+    assert(v1[28] == 7340032);
+    assert(v1[29] == 29);
+    assert(v1[30] == 15728640);
+    assert(v1[31] == 32505856);
+    assert(v1[32] == 67108864);
+    assert(v1[33] == 33);
+    assert(v1[34] == 142606336);
+    assert(v1[35] == 293601280);
+    assert(v1[36] == 603979776);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..59c75a8
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator>>= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] >>= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  0);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] ==  0);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  0);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  0);
+    assert(v1[23] ==  0);
+    assert(v1[24] ==  0);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  0);
+    assert(v1[27] ==  0);
+    assert(v1[28] ==  0);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  0);
+    assert(v1[31] ==  0);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  0);
+    assert(v1[35] ==  0);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..a68a87b
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] -= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..e3574a8
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] ^= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  6);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 12);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 27);
+    assert(v1[23] == 25);
+    assert(v1[24] == 23);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 14);
+    assert(v1[29] == 29);
+    assert(v1[30] == 13);
+    assert(v1[31] == 11);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 52);
+    assert(v1[35] == 52);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp b/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..f2a128c
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = 51;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 51);
+    assert(v1[ 4] == 51);
+    assert(v1[ 5] == 51);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 51);
+    assert(v1[ 8] == 51);
+    assert(v1[ 9] == 51);
+    assert(v1[10] == 10);
+    assert(v1[11] == 51);
+    assert(v1[12] == 51);
+    assert(v1[13] == 51);
+    assert(v1[14] == 14);
+    assert(v1[15] == 51);
+    assert(v1[16] == 51);
+    assert(v1[17] == 51);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 51);
+    assert(v1[23] == 51);
+    assert(v1[24] == 51);
+    assert(v1[25] == 25);
+    assert(v1[26] == 51);
+    assert(v1[27] == 51);
+    assert(v1[28] == 51);
+    assert(v1[29] == 29);
+    assert(v1[30] == 51);
+    assert(v1[31] == 51);
+    assert(v1[32] == 51);
+    assert(v1[33] == 33);
+    assert(v1[34] == 51);
+    assert(v1[35] == 51);
+    assert(v1[36] == 51);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.gslice.array/types.pass.cpp b/test/numerics/numarray/template.gslice.array/types.pass.cpp
new file mode 100644
index 0000000..a217259
--- /dev/null
+++ b/test/numerics/numarray/template.gslice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class gslice_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::gslice_array<int>::value_type, int>::value), "");
+}
diff --git a/test/numerics/numarray/template.indirect.array/default.fail.cpp b/test/numerics/numarray/template.indirect.array/default.fail.cpp
new file mode 100644
index 0000000..32458d9
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// indirect_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::indirect_array<int> ia;
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
new file mode 100644
index 0000000..43bbe32
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// const indirect_array& operator=(const indirect_array& ia) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+                -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+                -36, -37};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a1, N1);
+    const std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, S);
+    v1[ia] = v2[ia];
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] == -5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] == -8);
+    assert(v1[ 9] == -9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -11);
+    assert(v1[12] == -12);
+    assert(v1[13] == -13);
+    assert(v1[14] == 14);
+    assert(v1[15] == -15);
+    assert(v1[16] == -16);
+    assert(v1[17] == -17);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -22);
+    assert(v1[23] == -23);
+    assert(v1[24] == -24);
+    assert(v1[25] == 25);
+    assert(v1[26] == -26);
+    assert(v1[27] == -27);
+    assert(v1[28] == -28);
+    assert(v1[29] == 29);
+    assert(v1[30] == -30);
+    assert(v1[31] == -31);
+    assert(v1[32] == -32);
+    assert(v1[33] == 33);
+    assert(v1[34] == -34);
+    assert(v1[35] == -35);
+    assert(v1[36] == -36);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..cd547dd
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..58db230
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] += v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  3);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  4);
+    assert(v1[ 9] ==  4);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] ==  5);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  6);
+    assert(v1[16] ==  6);
+    assert(v1[17] ==  6);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 10);
+    assert(v1[23] == 10);
+    assert(v1[24] == 10);
+    assert(v1[25] == 25);
+    assert(v1[26] == 11);
+    assert(v1[27] == 11);
+    assert(v1[28] == 11);
+    assert(v1[29] == 29);
+    assert(v1[30] == 12);
+    assert(v1[31] == 12);
+    assert(v1[32] == 12);
+    assert(v1[33] == 33);
+    assert(v1[34] == 13);
+    assert(v1[35] == 13);
+    assert(v1[36] == 13);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..17e71dc
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] &= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  3);
+    assert(v1[12] ==  8);
+    assert(v1[13] ==  9);
+    assert(v1[14] == 14);
+    assert(v1[15] == 10);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  4);
+    assert(v1[23] ==  6);
+    assert(v1[24] ==  8);
+    assert(v1[25] == 25);
+    assert(v1[26] == 16);
+    assert(v1[27] == 17);
+    assert(v1[28] == 16);
+    assert(v1[29] == 29);
+    assert(v1[30] == 18);
+    assert(v1[31] == 20);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  2);
+    assert(v1[35] ==  3);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..d9466a1
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] /= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  1);
+    assert(v1[ 9] ==  1);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] ==  1);
+    assert(v1[13] ==  1);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  1);
+    assert(v1[16] ==  1);
+    assert(v1[17] ==  1);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  1);
+    assert(v1[23] ==  1);
+    assert(v1[24] ==  1);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  1);
+    assert(v1[27] ==  1);
+    assert(v1[28] ==  1);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  1);
+    assert(v1[31] ==  1);
+    assert(v1[32] ==  1);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  1);
+    assert(v1[35] ==  1);
+    assert(v1[36] ==  1);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..e69c1fe
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] %= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..8b605f3
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] *= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  8);
+    assert(v1[ 5] == 15);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] == 40);
+    assert(v1[ 9] == 54);
+    assert(v1[10] == 10);
+    assert(v1[11] == 77);
+    assert(v1[12] == 96);
+    assert(v1[13] == 117);
+    assert(v1[14] == 14);
+    assert(v1[15] == 150);
+    assert(v1[16] == 176);
+    assert(v1[17] == 204);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 286);
+    assert(v1[23] == 322);
+    assert(v1[24] == 360);
+    assert(v1[25] == 25);
+    assert(v1[26] == 416);
+    assert(v1[27] == 459);
+    assert(v1[28] == 504);
+    assert(v1[29] == 29);
+    assert(v1[30] == 570);
+    assert(v1[31] == 620);
+    assert(v1[32] == 672);
+    assert(v1[33] == 33);
+    assert(v1[34] == 748);
+    assert(v1[35] == 805);
+    assert(v1[36] == 864);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..102f421
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] |= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  7);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 31);
+    assert(v1[23] == 31);
+    assert(v1[24] == 31);
+    assert(v1[25] == 25);
+    assert(v1[26] == 26);
+    assert(v1[27] == 27);
+    assert(v1[28] == 30);
+    assert(v1[29] == 29);
+    assert(v1[30] == 31);
+    assert(v1[31] == 31);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 54);
+    assert(v1[35] == 55);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..0738ec3
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] <<= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] == 40);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] == 256);
+    assert(v1[ 9] == 576);
+    assert(v1[10] == 10);
+    assert(v1[11] == 1408);
+    assert(v1[12] == 3072);
+    assert(v1[13] == 6656);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15360);
+    assert(v1[16] == 32768);
+    assert(v1[17] == 69632);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 180224);
+    assert(v1[23] == 376832);
+    assert(v1[24] == 786432);
+    assert(v1[25] == 25);
+    assert(v1[26] == 1703936);
+    assert(v1[27] == 3538944);
+    assert(v1[28] == 7340032);
+    assert(v1[29] == 29);
+    assert(v1[30] == 15728640);
+    assert(v1[31] == 32505856);
+    assert(v1[32] == 67108864);
+    assert(v1[33] == 33);
+    assert(v1[34] == 142606336);
+    assert(v1[35] == 293601280);
+    assert(v1[36] == 603979776);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..3626afd
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] >>= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  0);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] ==  0);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  0);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  0);
+    assert(v1[23] ==  0);
+    assert(v1[24] ==  0);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  0);
+    assert(v1[27] ==  0);
+    assert(v1[28] ==  0);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  0);
+    assert(v1[31] ==  0);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  0);
+    assert(v1[35] ==  0);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..5499b77
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] -= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..b1e9b8b
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] ^= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  6);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 12);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 27);
+    assert(v1[23] == 25);
+    assert(v1[24] == 23);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 14);
+    assert(v1[29] == 29);
+    assert(v1[30] == 13);
+    assert(v1[31] == 11);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 52);
+    assert(v1[35] == 52);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp b/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..16511b5
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a1, N1);
+    std::valarray<std::size_t> ia(s, S);
+    v1[ia] = 51;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 51);
+    assert(v1[ 4] == 51);
+    assert(v1[ 5] == 51);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 51);
+    assert(v1[ 8] == 51);
+    assert(v1[ 9] == 51);
+    assert(v1[10] == 10);
+    assert(v1[11] == 51);
+    assert(v1[12] == 51);
+    assert(v1[13] == 51);
+    assert(v1[14] == 14);
+    assert(v1[15] == 51);
+    assert(v1[16] == 51);
+    assert(v1[17] == 51);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 51);
+    assert(v1[23] == 51);
+    assert(v1[24] == 51);
+    assert(v1[25] == 25);
+    assert(v1[26] == 51);
+    assert(v1[27] == 51);
+    assert(v1[28] == 51);
+    assert(v1[29] == 29);
+    assert(v1[30] == 51);
+    assert(v1[31] == 51);
+    assert(v1[32] == 51);
+    assert(v1[33] == 33);
+    assert(v1[34] == 51);
+    assert(v1[35] == 51);
+    assert(v1[36] == 51);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.indirect.array/types.pass.cpp b/test/numerics/numarray/template.indirect.array/types.pass.cpp
new file mode 100644
index 0000000..6f480da
--- /dev/null
+++ b/test/numerics/numarray/template.indirect.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class indirect_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::indirect_array<int>::value_type, int>::value), "");
+}
diff --git a/test/numerics/numarray/template.mask.array/default.fail.cpp b/test/numerics/numarray/template.mask.array/default.fail.cpp
new file mode 100644
index 0000000..aaebf05
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// mask_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::mask_array<int> s;
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
new file mode 100644
index 0000000..123f396
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void mask_array& operator=(const mask_array& ma) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b1[N1] = {true,  false, false, true,  true,  false,
+                   false, true,  false, false, false, true};
+    int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b2[N2] = {true,  false, true, true,
+                   false, false, true, true};
+    std::valarray<int> v1(a1, N1);
+    const std::valarray<int> v2(a2, N2);
+    std::valarray<bool> vb1(b1, N1);
+    std::valarray<bool> vb2(b2, N2);
+    v1[vb1] = v2[vb2];
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -8);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..33690ff
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..9ae44b3
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] += v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  5);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 11);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 16);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..a97a98c
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] &= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..0f1e297
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] /= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  2);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..984fb77
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] %= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..12ab523
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] *= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 12);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 55);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..d1ae959
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] |= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..6256f40
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] <<= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 12);
+    assert(v1[ 4] == 32);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 352);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..d2b5609
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] >>= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..d50954b
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] -= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  6);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..a1caff0
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] ^= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 14);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp b/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..689ab23
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    v1[vb] = -5;
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -5);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -5);
+    assert(v1[ 4] == -5);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -5);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -5);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.mask.array/types.pass.cpp b/test/numerics/numarray/template.mask.array/types.pass.cpp
new file mode 100644
index 0000000..391f6b3
--- /dev/null
+++ b/test/numerics/numarray/template.mask.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class mask_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::mask_array<int>::value_type, int>::value), "");
+}
diff --git a/test/numerics/numarray/template.slice.array/default.fail.cpp b/test/numerics/numarray/template.slice.array/default.fail.cpp
new file mode 100644
index 0000000..077bca7
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// slice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::slice_array<int> s;
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
new file mode 100644
index 0000000..75679f5
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// const slice_array& operator=(const slice_array& sa) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2[std::slice(2, 5, 2)];
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -3);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -5);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -9);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -11);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
new file mode 100644
index 0000000..ce9990b
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -4);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..313153a
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] += v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  6);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  8);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..543b000
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] &= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  0);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..6d9af9b
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] /= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -2);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -2);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -2);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..3b1ca89
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] %= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  2);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  3);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..acf4be1
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] *= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -8);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -21);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -40);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -65);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..c747829
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] |= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..bea499f
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] <<= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  2);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 56);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 160);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 416);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..a113622
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] >>= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  0);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..45429ef
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] -= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  2);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 10);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 18);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..2d378ab
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] ^= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  8);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp b/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..660f74b
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    v1[std::slice(1, 5, 3)] = 20;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == 20);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == 20);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 20);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 20);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 20);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.slice.array/types.pass.cpp b/test/numerics/numarray/template.slice.array/types.pass.cpp
new file mode 100644
index 0000000..ef67fc3
--- /dev/null
+++ b/test/numerics/numarray/template.slice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class slice_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::slice_array<int>::value_type, int>::value), "");
+}
diff --git a/test/numerics/numarray/template.valarray/types.pass.cpp b/test/numerics/numarray/template.valarray/types.pass.cpp
new file mode 100644
index 0000000..7b3a8eb
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T>
+// class valarray
+// {
+// public:
+//     typedef T value_type;
+//     ...
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::valarray<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::valarray<double>::value_type, double>::value), "");
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp b/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
new file mode 100644
index 0000000..936c3c0
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type& operator[](size_t i);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {5, 4, 3, 2, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i] == a[i]);
+            v[i] = i;
+            assert(v[i] == i);
+        }
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp b/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
new file mode 100644
index 0000000..de7ea5e
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// const value_type& operator[](size_t i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {5, 4, 3, 2, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i] == a[i]);
+        }
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
new file mode 100644
index 0000000..f21b4c8
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2(a, N-2);
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == v[i][j]);
+        }
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
new file mode 100644
index 0000000..248e2df
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const gslice_array<value_type>& ga);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(24);
+    v = v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                          strides(st, sizeof(st)/sizeof(st[0])))];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
new file mode 100644
index 0000000..99e97d2
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(24);
+    v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
new file mode 100644
index 0000000..b64e76f
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(initializer_list<value_type> il);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2;
+        v2 = {1, 2, 3, 4, 5};
+        assert(v2.size() == N);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2;
+        v2 = {1, 2.5, 3, 4.25, 5};
+        assert(v2.size() == N);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2(a, N-2);
+        v2 = {T(1), T(2), T(3), T(4), T(5)};
+        assert(v2.size() == N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < a[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
new file mode 100644
index 0000000..34cace9
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(5);
+    v2 = v1[vb];
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..fa7e6b6
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(valarray&& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2(a, N-2);
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < a[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
new file mode 100644
index 0000000..d5cac15
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::valarray<int> v(5);
+    v = v1[std::slice(1, 5, 3)];
+    assert(v.size() == 5);
+    assert(v[0] == 1);
+    assert(v[1] == 4);
+    assert(v[2] == 7);
+    assert(v[3] == 10);
+    assert(v[4] == 13);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp b/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
new file mode 100644
index 0000000..7830b61
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        v = 7;
+        assert(v.size() == N);
+        for (int i = 0; i < v.size(); ++i)
+            assert(v[i] == 7);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
new file mode 100644
index 0000000..36b80f9
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  2,  0,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 &= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
new file mode 100644
index 0000000..fe811a8
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 &= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
new file mode 100644
index 0000000..f50c567
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 /= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
new file mode 100644
index 0000000..15296ff
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v2 /= 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
new file mode 100644
index 0000000..f9ceaee
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 -= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
new file mode 100644
index 0000000..cb5c833
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {-2,  -1,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 -= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
new file mode 100644
index 0000000..80cd263
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  1,  2,  1,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v2 %= v1;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v2[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
new file mode 100644
index 0000000..6cc7386
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {1,  2,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 %= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
new file mode 100644
index 0000000..02fec8e
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  7, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 |= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
new file mode 100644
index 0000000..035a159
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 |= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
new file mode 100644
index 0000000..98f3d81
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 += v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
new file mode 100644
index 0000000..8860e32
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 += 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
new file mode 100644
index 0000000..21aa783
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 <<= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
new file mode 100644
index 0000000..6a35d0d
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 <<= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
new file mode 100644
index 0000000..392f3f9
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 >>= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
new file mode 100644
index 0000000..7fdaecb
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v2 >>= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
new file mode 100644
index 0000000..7ca7c64
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 *= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
new file mode 100644
index 0000000..e6a83ea
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 *= 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
new file mode 100644
index 0000000..b2a0192
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  5, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 ^= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
new file mode 100644
index 0000000..778891c
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 ^= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
new file mode 100644
index 0000000..c7fefdc
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == v[i][j]);
+        }
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
new file mode 100644
index 0000000..6fcf158
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<float> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<double> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<std::valarray<double> > v;
+        assert(v.size() == 0);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
new file mode 100644
index 0000000..d04828d
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const gslice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                                         strides(st, sizeof(st)/sizeof(st[0])))]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
new file mode 100644
index 0000000..2c1fc83
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(v1[ia]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..129305b
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(initializer_list<value_type>);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v = {1, 2, 3, 4, 5};
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v = {1, 2, 3, 4, 5};
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+#endif
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
new file mode 100644
index 0000000..b6d9728
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(v1[vb]);
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
new file mode 100644
index 0000000..fa4a096
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < v2[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
new file mode 100644
index 0000000..11d8778
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type* p, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i].size() == a[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v[i][j] == a[i][j]);
+        }
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
new file mode 100644
index 0000000..339497a
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// explicit valarray(size_t);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 0);
+    }
+    {
+        std::valarray<double> v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 0);
+    }
+    {
+        std::valarray<std::valarray<double> > v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i].size() == 0);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
new file mode 100644
index 0000000..e22ab2f
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::valarray<int> v(v1[std::slice(1, 5, 3)]);
+    assert(v.size() == 5);
+    assert(v[0] == 1);
+    assert(v[1] == 4);
+    assert(v[2] == 7);
+    assert(v[3] == 10);
+    assert(v[4] == 13);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp b/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
new file mode 100644
index 0000000..ae256c3
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type& x, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v(5, 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 5);
+    }
+    {
+        std::valarray<double> v(2.5, 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 2.5);
+    }
+    {
+        std::valarray<std::valarray<double> > v(std::valarray<double>(10), 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i].size() == 10);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
new file mode 100644
index 0000000..f0352c5
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(const value_type&)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(const T& t) {return t + 5;}
+
+int main()
+{
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+    }
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1+v1).apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
new file mode 100644
index 0000000..88e5bde
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(value_type)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(T t) {return t + 5;}
+
+int main()
+{
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+    }
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1+v1).apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
new file mode 100644
index 0000000..2988dfd
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray cshift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(0);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(10);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(17);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-10);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-17);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.cshift(-17);
+        assert(v2.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 10, 12, 14, 16, 18, 20, 2, 4, 6};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).cshift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {16, 18, 20, 2, 4, 6, 8, 10, 12, 14};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).cshift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
new file mode 100644
index 0000000..9f781fb
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type max() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, -5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.max() == 4.0);
+    }
+    {
+        typedef double T;
+        std::valarray<T> v1;
+        v1.max();
+    }
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, -5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert((2*v1).max() == 8.0);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
new file mode 100644
index 0000000..fe7f1e0
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type min() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.min() == -3.0);
+    }
+    {
+        typedef double T;
+        std::valarray<T> v1;
+        v1.min();
+    }
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert((2*v1).min() == -6.0);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
new file mode 100644
index 0000000..e97463e
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void resize(size_t n, value_type x = value_type());
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        v1.resize(8);
+        assert(v1.size() == 8);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+        v1.resize(0);
+        assert(v1.size() == 0);
+        v1.resize(80);
+        assert(v1.size() == 80);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+        v1.resize(40);
+        assert(v1.size() == 40);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
new file mode 100644
index 0000000..51c105c
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray shift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(0);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(1);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(9);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(90);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-1);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-9);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-90);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.shift(-90);
+        assert(v2.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 10, 12, 14, 16, 18, 20, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).shift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 2, 4, 6, 8, 10, 12, 14};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).shift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
new file mode 100644
index 0000000..eabbd97
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// size_t size() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = 0;
+        std::valarray<T> v1(a1, N1);
+        assert(v1.size() == N1);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        assert(v1.size() == N1);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
new file mode 100644
index 0000000..e26bb74
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type sum() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, 3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.sum() == 16.5);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp b/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
new file mode 100644
index 0000000..c92f383
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void swap(valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = 0;
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = 0;
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1;
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        const unsigned N2 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
new file mode 100644
index 0000000..b2a3790
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// gslice_array<value_type> operator[](const gslice& gs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
new file mode 100644
index 0000000..3ed7dec
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const gslice& gs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                                         strides(st, sizeof(st)/sizeof(st[0])))]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
new file mode 100644
index 0000000..7aa8e33
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<size_t>& vs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    const std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
new file mode 100644
index 0000000..d680aff
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(24);
+    v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
new file mode 100644
index 0000000..c6369f8
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](slice s) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2 = v1[std::slice(1, 5, 3)];
+    assert(v2.size() == 5);
+    assert(v2[0] ==  1);
+    assert(v2[1] ==  4);
+    assert(v2[2] ==  7);
+    assert(v2[3] == 10);
+    assert(v2[4] == 13);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
new file mode 100644
index 0000000..96c3772
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// slice_array<value_type> operator[](slice s);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -4);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
new file mode 100644
index 0000000..c941d3d
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<bool>& vb) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(v1[vb]);
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp b/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
new file mode 100644
index 0000000..b489303
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// mask_array<value_type> operator[](const valarray<bool>& vb);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(5);
+    v2 = v1[vb];
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp b/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
new file mode 100644
index 0000000..fe1026a
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator~() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == ~v[i]);
+    }
+    {
+        typedef std::valarray<int> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == ~v[i][j]);
+        }
+    }
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == ~(2*v[i]));
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp b/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
new file mode 100644
index 0000000..dd98b38
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator-() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == -v[i][j]);
+        }
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -2*v[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp b/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
new file mode 100644
index 0000000..ea2ac72
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray<bool> operator!() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<bool> v2 = !v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == !v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<bool> v2 = !(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == !2*v[i]);
+    }
+}
diff --git a/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp b/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
new file mode 100644
index 0000000..8b28376
--- /dev/null
+++ b/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator+() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == +v[i][j]);
+        }
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +2*v[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp b/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..d96dd17
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  2,  0,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 & v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
new file mode 100644
index 0000000..82a978f
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 & 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
new file mode 100644
index 0000000..e179b21
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 & v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..e2fdc6f
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6, 14, 24, 36, 50};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 / v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
new file mode 100644
index 0000000..eaf2093
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6, 12, 18, 24, 30};
+        T a2[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 / 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
new file mode 100644
index 0000000..6b1a7c0
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {3,  1,  1,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 / v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9b5db5f
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {7,  9, 11, 13, 15};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 - v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
new file mode 100644
index 0000000..abd6987
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {-2,  -1,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 - 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
new file mode 100644
index 0000000..54facf2
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0, -1, -2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 - v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9ee679d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6,  7,  8,  9, 10};
+        T a2[] = {1,  2,  3,  4,  5};
+        T a3[] = {0,  1,  2,  1,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 % v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
new file mode 100644
index 0000000..a3ba746
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {1,  2,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 % 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
new file mode 100644
index 0000000..5df530d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {0,  1,  0,  3,  3};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 % v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..c4dc00a
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  7, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 | v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
new file mode 100644
index 0000000..a8dc9f0
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 | 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
new file mode 100644
index 0000000..0124772
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 | v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..833f4b0
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 + v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
new file mode 100644
index 0000000..034963c
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 + 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
new file mode 100644
index 0000000..e2dd970
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 + v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..5a048bf
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 << v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
new file mode 100644
index 0000000..e4635e9
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 << 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
new file mode 100644
index 0000000..b7aad3d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 6,  12, 24, 48, 96};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 << v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9daccbc
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {64, 256, 768, 2048, 5120};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = { 1,   2,   3,    4,    5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 >> v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
new file mode 100644
index 0000000..3ce7868
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 8,  16, 24, 32, 40};
+        T a2[] = { 1,   2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 >> 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
new file mode 100644
index 0000000..ddf201b
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {20,  10,  5,  2,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 40 >> v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..7b6addd
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 * v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
new file mode 100644
index 0000000..966916c1
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 * 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
new file mode 100644
index 0000000..cafb304
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 6 * v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..d218576
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  5, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 ^ v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
new file mode 100644
index 0000000..99321b0
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 ^ 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
new file mode 100644
index 0000000..35126a2
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 ^ v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9a24512
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 && v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
new file mode 100644
index 0000000..bc8f5d2
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 && 5;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 && 0;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
new file mode 100644
index 0000000..8b02ec2
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 5 && v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  false,  false,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 0 && v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..4ac7215
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {false,  false,  true,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 == v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..e71ce24
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 == 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..33c1680
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  false,  false,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 == v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..5b23ccf
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {false,  false,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 >= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..daba8aa
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 >= 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..4804c5f
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  false,  false,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 >= v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..57f9014
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {false,  false,  false,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 > v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
new file mode 100644
index 0000000..91ef3e9
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 > 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
new file mode 100644
index 0000000..c03bc96
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  false,  false,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 > v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..dd3ca9d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {true,  true,  true,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 <= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..919765e
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  false,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 <= 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..2ad6d7a
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 <= v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..ea476e4
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {true,  true,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 < v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
new file mode 100644
index 0000000..0f45c4d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  false,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 < 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
new file mode 100644
index 0000000..e80ba4e
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 < v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..3bdfefe
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 != v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..73afabc
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 != 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..50c50bb
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  true,  true,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 != v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..2c9cfb1
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4,  0};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 || v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
new file mode 100644
index 0000000..a7e404c
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 || 5;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 || 0;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
new file mode 100644
index 0000000..a2c4d44
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 5 || v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 0 || v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
new file mode 100644
index 0000000..5f89f81
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   void
+//   swap(valarray<T>& x, valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = 0;
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = 0;
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1;
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        const unsigned N2 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
new file mode 100644
index 0000000..ff70354
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   abs(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5,  -2.5,  3.4,  -4.5,  -5.0};
+        T a3[] = {1.5,   2.5,  3.4,   4.5,   5.0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = abs(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
new file mode 100644
index 0000000..248bb30
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   acos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {2.6905658417935308e+00,
+                  2.0943951023931957e+00,
+                  1.5707963267948966e+00,
+                  1.0471975511965976e+00,
+                  7.2273424781341566e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = acos(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
new file mode 100644
index 0000000..805c38d
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   asin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.1197695149986342e+00,
+                  -5.2359877559829882e-01,
+                  0.0000000000000000e+00,
+                  5.2359877559829882e-01,
+                  8.4806207898148100e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = asin(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..cf8b6cd
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a2[] = {-.8,  .25, 0.375, -.5, .75};
+        T a3[] = {-2.2974386674766221e+00,
+                  -1.1071487177940904e+00,
+                   0.0000000000000000e+00,
+                   2.3561944901923448e+00,
+                   7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = atan2(v1, v2);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
new file mode 100644
index 0000000..45257f4
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-8.7605805059819342e-01,
+                  -5.8800260354756750e-01,
+                   0.0000000000000000e+00,
+                   5.8800260354756750e-01,
+                   7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan2(v1, .75);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
new file mode 100644
index 0000000..214ec7f
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {2.4468543773930902e+00,
+                  2.1587989303424640e+00,
+                  1.5707963267948966e+00,
+                  9.8279372324732905e-01,
+                  7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan2(.75, v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
new file mode 100644
index 0000000..84a9bc3
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.3281510178650666e-01,
+                  -4.6364760900080615e-01,
+                   0.0000000000000000e+00,
+                   4.6364760900080615e-01,
+                   6.4350110879328437e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
new file mode 100644
index 0000000..86e2b33
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   cos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {6.2160996827066450e-01,
+                  8.7758256189037276e-01,
+                  1.0000000000000000e+00,
+                  8.7758256189037276e-01,
+                  7.3168886887382090e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = cos(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
new file mode 100644
index 0000000..dc0ab15
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   cosh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {1.4330863854487743e+00,
+                  1.1276259652063807e+00,
+                  1.0000000000000000e+00,
+                  1.1276259652063807e+00,
+                  1.2946832846768448e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = cosh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
new file mode 100644
index 0000000..10f0e98
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   exp(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {4.0656965974059911e-01,
+                  6.0653065971263342e-01,
+                  1.0000000000000000e+00,
+                  1.6487212707001282e+00,
+                  2.1170000166126748e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = exp(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
new file mode 100644
index 0000000..68491ef
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   log10(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {-3.0102999566398120e-01,
+                  -1.2493873660829995e-01,
+                   0.0000000000000000e+00,
+                   4.7712125471966244e-01,
+                   8.4509804001425681e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = log10(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
new file mode 100644
index 0000000..e79d216
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   log(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {-6.9314718055994529e-01,
+                  -2.8768207245178090e-01,
+                   0.0000000000000000e+00,
+                   1.0986122886681098e+00,
+                   1.9459101490553132e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = log(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..2969a48
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a2[] = {-.8,  .25, 0.375, -.5, .75};
+        T a3[] = {1.0879426248455297e+00,
+                  8.4089641525371450e-01,
+                  0.0000000000000000e+00,
+                  1.4142135623730949e+00,
+                  8.0592744886765644e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = pow(v1, v2);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
new file mode 100644
index 0000000..f8a3bbf
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a3[] = {8.1000000000000005e-01,
+                  2.5000000000000000e-01,
+                  0.0000000000000000e+00,
+                  2.5000000000000000e-01,
+                  5.6250000000000000e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = pow(v1, 2.0);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
new file mode 100644
index 0000000..a32134c
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a3[] = {1.8660659830736148e+00,
+                  1.4142135623730951e+00,
+                  1.0000000000000000e+00,
+                  1.4142135623730951e+00,
+                  1.6817928305074290e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = pow(2.0, v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
new file mode 100644
index 0000000..8a5df20
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.8332690962748330e-01,
+                  -4.7942553860420301e-01,
+                   0.0000000000000000e+00,
+                   4.7942553860420301e-01,
+                   6.8163876002333423e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sin(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
new file mode 100644
index 0000000..e5da9af
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sinh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.0265167257081753e+00,
+                  -5.2109530549374738e-01,
+                   0.0000000000000000e+00,
+                   5.2109530549374738e-01,
+                   8.2231673193582999e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sinh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
new file mode 100644
index 0000000..97fe6d2
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sqrt(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {7.0710678118654757e-01,
+                  8.6602540378443860e-01,
+                  1.0000000000000000e+00,
+                  1.7320508075688772e+00,
+                  2.6457513110645907e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sqrt(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
new file mode 100644
index 0000000..d1fdb7a
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   tan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.2601582175503390e+00,
+                  -5.4630248984379048e-01,
+                   0.0000000000000000e+00,
+                   5.4630248984379048e-01,
+                   9.3159645994407259e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = tan(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
new file mode 100644
index 0000000..03e5d51
--- /dev/null
+++ b/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   tanh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.1629787019902447e-01,
+                  -4.6211715726000974e-01,
+                   0.0000000000000000e+00,
+                   4.6211715726000974e-01,
+                   6.3514895238728730e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = tanh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/test/numerics/numarray/valarray.range/begin_const.pass.cpp b/test/numerics/numarray/valarray.range/begin_const.pass.cpp
new file mode 100644
index 0000000..5d52624
--- /dev/null
+++ b/test/numerics/numarray/valarray.range/begin_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   begin(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        assert(v[0] == 1);
+    }
+}
diff --git a/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp b/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp
new file mode 100644
index 0000000..aa68fc5
--- /dev/null
+++ b/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   begin(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        *begin(v) = 10;
+        assert(v[0] == 10);
+    }
+}
diff --git a/test/numerics/numarray/valarray.range/end_const.pass.cpp b/test/numerics/numarray/valarray.range/end_const.pass.cpp
new file mode 100644
index 0000000..f7062f7
--- /dev/null
+++ b/test/numerics/numarray/valarray.range/end_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   end(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        assert(v[v.size()-1] == 5);
+        assert(end(v) - begin(v) == v.size());
+    }
+}
diff --git a/test/numerics/numarray/valarray.range/end_non_const.pass.cpp b/test/numerics/numarray/valarray.range/end_non_const.pass.cpp
new file mode 100644
index 0000000..38597d7
--- /dev/null
+++ b/test/numerics/numarray/valarray.range/end_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   end(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        *(end(v) - 1) = 10;
+        assert(v[v.size()-1] == 10);
+        assert(end(v) - begin(v) == v.size());
+    }
+}
diff --git a/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp b/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numarray/version.pass.cpp b/test/numerics/numarray/version.pass.cpp
new file mode 100644
index 0000000..3ca013f
--- /dev/null
+++ b/test/numerics/numarray/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+#include <valarray>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp b/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp
new file mode 100644
index 0000000..d3724ba
--- /dev/null
+++ b/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T> 
+//   requires HasPlus<T, Iter::reference> 
+//         && HasAssign<T, HasPlus<T, Iter::reference>::result_type> 
+//   T
+//   accumulate(Iter first, Iter last, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+    assert(std::accumulate(first, last, init) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    unsigned sa = sizeof(ia) / sizeof(ia[0]);
+    test(Iter(ia), Iter(ia), 0, 0);
+    test(Iter(ia), Iter(ia), 10, 10);
+    test(Iter(ia), Iter(ia+1), 0, 1);
+    test(Iter(ia), Iter(ia+1), 10, 11);
+    test(Iter(ia), Iter(ia+2), 0, 3);
+    test(Iter(ia), Iter(ia+2), 10, 13);
+    test(Iter(ia), Iter(ia+sa), 0, 21);
+    test(Iter(ia), Iter(ia+sa), 10, 31);
+}
+
+int main()
+{
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp b/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
new file mode 100644
index 0000000..3531350
--- /dev/null
+++ b/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T,
+//           Callable<auto, const T&, Iter::reference> BinaryOperation> 
+//   requires HasAssign<T, BinaryOperation::result_type> 
+//         && CopyConstructible<BinaryOperation> 
+//   T
+//   accumulate(Iter first, Iter last, T init, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+    assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    unsigned sa = sizeof(ia) / sizeof(ia[0]);
+    test(Iter(ia), Iter(ia), 1, 1);
+    test(Iter(ia), Iter(ia), 10, 10);
+    test(Iter(ia), Iter(ia+1), 1, 1);
+    test(Iter(ia), Iter(ia+1), 10, 10);
+    test(Iter(ia), Iter(ia+2), 1, 2);
+    test(Iter(ia), Iter(ia+2), 10, 20);
+    test(Iter(ia), Iter(ia+sa), 1, 720);
+    test(Iter(ia), Iter(ia+sa), 10, 7200);
+}
+
+int main()
+{
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
new file mode 100644
index 0000000..8e14a90
--- /dev/null
+++ b/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+//           OutputIterator<auto, const InIter::value_type&> OutIter> 
+//   requires HasMinus<InIter::value_type, InIter::value_type> 
+//         && Constructible<InIter::value_type, InIter::reference> 
+//         && OutputIterator<OutIter,
+//                           HasMinus<InIter::value_type, InIter::value_type>::result_type> 
+//         && MoveAssignable<InIter::value_type> 
+//   OutIter
+//   adjacent_difference(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {15, 10, 6, 3, 1};
+    int ir[] = {15, -5, -4, -3, -2};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib));
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
new file mode 100644
index 0000000..2a91355
--- /dev/null
+++ b/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+//           OutputIterator<auto, const InIter::value_type&> OutIter, 
+//           Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation> 
+//   requires Constructible<InIter::value_type, InIter::reference> 
+//         && OutputIterator<OutIter, BinaryOperation::result_type> 
+//         && MoveAssignable<InIter::value_type> 
+//         && CopyConstructible<BinaryOperation> 
+//   OutIter
+//   adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {15, 10, 6, 3, 1};
+    int ir[] = {15, 25, 16, 9, 4};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib),
+                                         std::plus<int>());
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp b/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp
new file mode 100644
index 0000000..810d66e
--- /dev/null
+++ b/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T> 
+//   requires HasMultiply<Iter1::reference, Iter2::reference> 
+//         && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type> 
+//         && HasAssign<T,
+//                      HasPlus<T,
+//                              HasMultiply<Iter1::reference,
+//                                          Iter2::reference>::result_type>::result_type>
+//   T
+//   inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+    assert(std::inner_product(first1, last1, first2, init) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int a[] = {1, 2, 3, 4, 5, 6};
+    int b[] = {6, 5, 4, 3, 2, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    test(Iter1(a), Iter1(a), Iter2(b), 0, 0);
+    test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 0, 6);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 10, 16);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 0, 16);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 10, 26);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 0, 56);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp b/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
new file mode 100644
index 0000000..c906310
--- /dev/null
+++ b/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T, 
+//           class BinaryOperation1,
+//           Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2> 
+//   requires Callable<BinaryOperation1, const T&, BinaryOperation2::result_type> 
+//         && HasAssign<T, BinaryOperation1::result_type> 
+//         && CopyConstructible<BinaryOperation1> 
+//         && CopyConstructible<BinaryOperation2> 
+//   T
+//   inner_product(Iter1 first1, Iter1 last1, Iter2 first2,
+//                 T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+    assert(std::inner_product(first1, last1, first2, init,
+           std::multiplies<int>(), std::plus<int>()) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int a[] = {1, 2, 3, 4, 5, 6};
+    int b[] = {6, 5, 4, 3, 2, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    test(Iter1(a), Iter1(a), Iter2(b), 1, 1);
+    test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 1, 7);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 10, 70);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 1, 49);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 10, 490);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 1, 117649);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/test/numerics/numeric.ops/iterators.h b/test/numerics/numeric.ops/iterators.h
new file mode 100644
index 0000000..01b0e33
--- /dev/null
+++ b/test/numerics/numeric.ops/iterators.h
@@ -0,0 +1,314 @@
+#ifndef ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class Iter>
+inline
+Iter
+base(output_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(input_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(forward_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class Iter>
+inline
+Iter
+base(bidirectional_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+template <class Iter>
+inline
+Iter
+base(random_access_iterator<Iter> i)
+{
+    return i.base();
+}
+
+template <class Iter>
+inline
+Iter
+base(Iter i)
+{
+    return i;
+}
+
+#endif
diff --git a/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp b/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
new file mode 100644
index 0000000..812eba3
--- /dev/null
+++ b/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter> 
+//   requires HasPlus<InIter::value_type, InIter::reference> 
+//         && HasAssign<InIter::value_type,
+//                      HasPlus<InIter::value_type, InIter::reference>::result_type> 
+//         && Constructible<InIter::value_type, InIter::reference> 
+//   OutIter
+//   partial_sum(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5};
+    int ir[] = {1, 3, 6, 10, 15};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib));
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp b/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
new file mode 100644
index 0000000..4f7053e
--- /dev/null
+++ b/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template<InputIterator InIter,
+//          OutputIterator<auto, const InIter::value_type&> OutIter, 
+//          Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation> 
+//   requires HasAssign<InIter::value_type, BinaryOperation::result_type> 
+//         && Constructible<InIter::value_type, InIter::reference> 
+//         && CopyConstructible<BinaryOperation> 
+//   OutIter
+//   partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "../iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5};
+    int ir[] = {1, -1, -4, -8, -13};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib), std::minus<int>());
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/test/numerics/numeric.ops/version.pass.cpp b/test/numerics/numeric.ops/version.pass.cpp
new file mode 100644
index 0000000..f2f9d48
--- /dev/null
+++ b/test/numerics/numeric.ops/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+#include <numeric>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/numeric.requirements/nothing_to_do.pass.cpp b/test/numerics/numeric.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numeric.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/numerics.general/nothing_to_do.pass.cpp b/test/numerics/numerics.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/numerics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/nothing_to_do.pass.cpp b/test/numerics/rand/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp b/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
new file mode 100644
index 0000000..84a4658
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine& operator=(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
new file mode 100644
index 0000000..6fa11fb
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..ae8e5bf
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0 0";
+    std::ranlux24 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0 0";
+    std::ranlux48 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..6987a02
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> explicit discard_block_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux24 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux48 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
new file mode 100644
index 0000000..83cc88e
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e1;
+    std::ranlux24 e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+    std::ranlux48 e1;
+    std::ranlux48 e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
new file mode 100644
index 0000000..191d02d
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e1;
+    std::ranlux24 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::ranlux48 e1;
+    std::ranlux48 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
new file mode 100644
index 0000000..6434e42
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e;
+    assert(e() == 15039276u);
+    assert(e() == 16323925u);
+    assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+    std::ranlux48 e;
+    assert(e() == 23459059301164ull);
+    assert(e() == 28639057539807ull);
+    assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
new file mode 100644
index 0000000..dc26ff7
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t p, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const discard_block_engine<Engine, p, r>& x);
+// 
+// template <class charT, class traits,
+//           class Engine, size_t p, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            discard_block_engine<Engine, p, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
new file mode 100644
index 0000000..0c88e4a
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::ranlux24::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::ranlux48::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
new file mode 100644
index 0000000..64046bf
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux24 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux48 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
new file mode 100644
index 0000000..6ca0a51
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux24 e1;
+    std::ranlux24 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux48 e1;
+    std::ranlux48 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
new file mode 100644
index 0000000..47e7aec
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+// 
+//     // engine characteristics
+//     static constexpr size_t block_size = p;
+//     static constexpr size_t used_block = r;
+//     static constexpr result_type min() { return Engine::min(); }
+//     static constexpr result_type max() { return Engine::max(); }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    static_assert((E::block_size == 223), "");
+    static_assert((E::used_block == 23), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    static_assert((E::block_size == 389), "");
+    static_assert((E::used_block == 11), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
new file mode 100644
index 0000000..e60c273
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine& operator=(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
new file mode 100644
index 0000000..d0d1f33
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..54ca4fa
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0 0";
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0 0";
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..c861728
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> explicit independent_bits_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
new file mode 100644
index 0000000..5a30f2d
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 2066486613);
+}
+
+void
+test2()
+{
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 18223106896348967647ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
new file mode 100644
index 0000000..720957c
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
new file mode 100644
index 0000000..1bfde14
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+    // Temporary work around for lack of constexpr
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+
+    static const/*expr*/ result_type min() {return Min;}
+    static const/*expr*/ result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+   typedef std::independent_bits_engine<rand1<unsigned, 0, 10>, 16, unsigned> E;
+
+    E e;
+    assert(e() == 6958);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 100>, 16, unsigned> E;
+
+    E e;
+    assert(e() == 66);
+}
+
+void
+test3()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 32, unsigned> E;
+
+    E e(5);
+    assert(e() == 5);
+}
+
+void
+test4()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 7, unsigned> E;
+
+    E e(129);
+    assert(e() == 1);
+}
+
+void
+test5()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 1, unsigned> E;
+
+    E e(6);
+    assert(e() == 1);
+}
+
+void
+test6()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 11, unsigned> E;
+
+    E e(6);
+    assert(e() == 1365);
+}
+
+void
+test7()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 32, unsigned> E;
+
+    E e(6);
+    assert(e() == 2863311530u);
+}
+
+void
+test8()
+{
+    typedef std::independent_bits_engine<std::mt19937, 64, unsigned long long> E;
+
+    E e(6);
+    assert(e() == 16470362623952407241ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
new file mode 100644
index 0000000..2ee773f
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t w, class UIntType>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const independent_bits_engine<Engine, w, UIntType>& x);
+// 
+// template <class charT, class traits,
+//           class Engine, size_t w, class UIntType>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            independent_bits_engine<Engine, w, UIntType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
new file mode 100644
index 0000000..966e9f1
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+    // Temporary work around for lack of constexpr
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+
+    static const/*expr*/ result_type min() {return Min;}
+    static const/*expr*/ result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned>::result_type,
+        unsigned>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned long long>::result_type,
+        unsigned long long>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
new file mode 100644
index 0000000..dad2a84
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
new file mode 100644
index 0000000..6f23faa
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
new file mode 100644
index 0000000..140145c
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+// 
+//     // engine characteristics
+//     static constexpr result_type min() { return 0; }
+//     static constexpr result_type max() { return 2^w - 1; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
new file mode 100644
index 0000000..7fd103d
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine& operator=(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
new file mode 100644
index 0000000..2b853af
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..6395b80
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "1771550148 168070 677268843 1194115201 1259501992 "
+        "703671065 407145426 1010275440 1693606898 1702877348 745024267 "
+        "1793193459 416963415 664975744 742430420 1148079870 637806795 "
+        "1527921388 165317290 1791337459 1435426120 375508442 1863429808 "
+        "1910758855 653618747 991426424 578291095 1974930990 1157900898 "
+        "343583572 25567821 221638147 1335692731 1341167826 1019292670 "
+        "774852571 606325389 700907908 1211405961 1955012967 1403137269 "
+        "1010152376 1772753897 486628401 1145807831 1106352968 1560917450 "
+        "679350398 1819071734 1561434646 781928982 1427964481 1669276942 "
+        "811199786 1608612146 1272705739 1428231253 1857946652 2097152784 "
+        "197742477 1300609030 99924397 97128425 349867255 408729299 1860625187 "
+        "2018133942 1420442476 1948474080 1025729457 1583749330 15184745 "
+        "1806938869 1655319056 296727307 638820415 1383963552 880037807 "
+        "1075545360 1321008721 1507631161 597371974 544717293 340756290 "
+        "1899563128 1465595994 634440068 777915521 545718511 2135841687 "
+        "1902073804 712854586 135760289 1095544109 285050585 1956649285 "
+        "987446484 259432572 891434194 1488577086 330596852 801096775 "
+        "1458514382 1872871416 1682074633 1153627723 1538775345 51662594 "
+        "709823970 739804705 2114844452 1188863267 1037076781 1172179215 "
+        "1948572574 533634468 902793804 1283497773 273836696 315894151 "
+        "653420473 1954002600 1601768276 64415940 306945492 577163950 "
+        "210874151 813838307 857078006 1737226413 376658679 1868110244 "
+        "1117951768 1080937173 1746896638 1842856729 1883887269 2141922362 "
+        "1020763473 1872318475 978729834 1935067665 1189895487 1205729145 "
+        "1034046923 1788963337 188263312 898072753 1393688555 1119406056 "
+        "1900835472 1375045132 1312008157 559007303 2142269543 413383599 "
+        "628550348 573639243 1100665718 464587168 65992084 1027393936 "
+        "1641360472 1918007189 69800406 609352380 35938117 569027612 902394793 "
+        "1019770837 221470752 669768613 1839284764 1979413630 1335703733 "
+        "1526078440 1403144959 1139398206 753967943 1785700701 1187714882 "
+        "1063522909 1123137582 192083544 680202567 1109090588 327456556 "
+        "1709233078 191596027 1076438936 1306955024 1530346852 127901445 "
+        "8455468 377129974 1199230721 1336700752 1103107597 703058228 "
+        "844612202 530372344 1910850558 47387421 1871435357 1168551137 "
+        "1101007744 1918050856 803711675 309982095 73743043 301259382 "
+        "1647477295 1644236294 859823662 638826571 1487427444 335916581 "
+        "15468904 140348241 895842081 410006250 1847504174 536600445 "
+        "1359845362 1400027760 288242141 1910039802 1453396858 1761991428 "
+        "2137921913 357210187 1414819544 1933136424 943782705 841706193 "
+        "1081202962 1919045067 333546776 988345562 337850989 314809455 "
+        "1750287624 853099962 1450233962 142805884 1399258689 247367726 "
+        "2128513937 1151147433 654730608 351121428 12778440 18876380 "
+        "1575222551 587014441 411835569 380613902 1771550148";
+    std::knuth_b e1(10);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..3f08cf8
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "1894661934 884942216 1899568837 1561547157 525417712 "
+        "242729120 1476874187 1208468883 1983666902 1953485886 1507290666 "
+        "1317123450 632390874 696850315 1734917114 218976032 1690682513 "
+        "1944862534 456017951 2072049961 1348874775 1700965693 828093387 "
+        "2071522749 1077957279 1055942061 413360419 238964088 475007126 "
+        "1248050783 1516729632 1044035134 9617501 580065782 1737324341 "
+        "2022534575 219953662 941840747 415472792 1381878747 200458524 "
+        "1852054372 1849850586 1318041283 1026024576 101363422 660501483 "
+        "705453438 298717379 1873705814 673416290 868766340 614560427 "
+        "1668238166 532360730 969915708 1972423626 1966307090 97417947 "
+        "920896215 588041576 495024338 522400288 1068491480 878048146 "
+        "1995051285 17282737 560668414 2143274709 127339385 1299331283 "
+        "99667038 66663006 1566161755 773555006 272986904 1065825536 "
+        "1168683925 1185292013 1144552919 1489883454 811887358 279732868 "
+        "628609193 1562647158 1833265343 1742736292 639398211 357562689 "
+        "896869717 501615326 1775469607 1032409784 43371928 955037563 "
+        "1023543663 1354331571 1071539244 562210166 138213162 1518791327 "
+        "1335204647 1727874626 2114964448 1058152392 1055171537 348065433 "
+        "190278003 399246038 1389247438 1639480282 382424917 2144508195 "
+        "1531185764 1342593547 1359065400 1176108308 1412845568 968776497 "
+        "5573525 1332437854 323541262 329396230 2097079291 1110029273 "
+        "1071549822 739994612 1011644107 1074473050 478563727 894301674 "
+        "290189565 280656618 1121689914 1630931232 579945916 1870220126 "
+        "71516543 1535179528 1893792038 1107650479 1893348357 93154853 "
+        "138035708 683805596 1535656875 1326628479 1469623399 1751042846 "
+        "661214234 1947241260 1780560187 690441964 1403944207 1687457460 "
+        "1428487938 1877084153 1618585041 1383427538 461185097 869443256 "
+        "1254069404 1739961370 1245924391 138197640 1257913073 1915996843 "
+        "641653536 1755587965 1889101622 1732723706 2009073422 1611621773 "
+        "315899200 738279016 94909546 1711873548 1620302377 181922632 "
+        "1704446343 1345319468 2076463060 357902023 157605314 1025175647 "
+        "865799248 138769064 124418006 1591838311 675218651 1096276609 "
+        "1858759850 732186041 769493777 735387805 894450150 638142050 "
+        "720101232 1671055379 636619387 898507955 118193981 63865192 "
+        "1787942091 204050966 2100684950 1580797970 1951284753 1020070334 "
+        "960149537 1041144801 823914651 558983501 1742229329 708805658 "
+        "804904097 1023665826 1260041465 1180659188 590074436 301564006 "
+        "324841922 714752380 1967212989 290476911 815113546 815183409 "
+        "1989370850 1182975807 870784323 171062356 1711897606 2024645183 "
+        "1333203966 314683764 1785282634 603713754 1904315050 1874254109 "
+        "1298675767 1967311508 1946285744 753588304 1847558969 1457540010 "
+        "528986741 97857407 1864449494 1868752281 1171249392 1353422942 "
+        "832597170 457192338 335135800 1925268166 1845956613 296546482 "
+        "1894661934";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::knuth_b e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
new file mode 100644
index 0000000..36562b1
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::knuth_b e1;
+    std::knuth_b e2(std::minstd_rand0::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 152607844u);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
new file mode 100644
index 0000000..4ac5bd9
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::knuth_b e1;
+    std::knuth_b e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
new file mode 100644
index 0000000..648ff3a
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+    // Temporary work around for lack of constexpr
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+
+    static const/*expr*/ result_type min() {return Min;}
+    static const/*expr*/ result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+   typedef std::knuth_b E;
+
+    E e;
+    assert(e() == 152607844u);
+}
+
+void
+test2()
+{
+    typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+    typedef std::shuffle_order_engine<E0, 101> E;
+    E e;
+    e.discard(400);
+    assert(e() == 501);
+}
+
+void
+test3()
+{
+    typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+    typedef std::shuffle_order_engine<E0, 100> E;
+    E e;
+    e.discard(400);
+    assert(e() == 500);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
new file mode 100644
index 0000000..7c28be1
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t k>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const shuffle_order_engine<Engine, k>& x);
+// 
+// template <class charT, class traits,
+//           class Engine, size_t k>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            shuffle_order_engine<Engine, k>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
new file mode 100644
index 0000000..527db72
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+    // Temporary work around for lack of constexpr
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+
+    static const/*expr*/ result_type min() {return Min;}
+    static const/*expr*/ result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::shuffle_order_engine<rand1<unsigned long, 0, 10>, 16>::result_type,
+        unsigned long>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::shuffle_order_engine<rand1<unsigned long long, 0, 10>, 16>::result_type,
+        unsigned long long>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
new file mode 100644
index 0000000..2739c10
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::knuth_b E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
new file mode 100644
index 0000000..3f271da
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::knuth_b e1;
+    std::knuth_b e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp b/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
new file mode 100644
index 0000000..1289cf1
--- /dev/null
+++ b/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+// 
+//     // engine characteristics
+//     static constexpr size_t table_size = k;
+//     static constexpr result_type min() { return Engine::min; }
+//     static constexpr result_type max() { return Engine::max; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    static_assert(E::table_size == 256, "");
+    /*static_*/assert((E::min() == 1)/*, ""*/);
+    /*static_*/assert((E::max() == 2147483646)/*, ""*/);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.device/ctor.pass.cpp b/test/numerics/rand/rand.device/ctor.pass.cpp
new file mode 100644
index 0000000..63bd256
--- /dev/null
+++ b/test/numerics/rand/rand.device/ctor.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// explicit random_device(const string& token = "/dev/urandom");
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    try
+    {
+        std::random_device r("wrong file");
+        assert(false);
+    }
+    catch (const std::system_error& e)
+    {
+    }
+    {
+        std::random_device r;
+    }
+    {
+        std::random_device r("/dev/urandom");;
+    }
+    {
+        std::random_device r("/dev/random");;
+    }
+}
diff --git a/test/numerics/rand/rand.device/entropy.pass.cpp b/test/numerics/rand/rand.device/entropy.pass.cpp
new file mode 100644
index 0000000..70c7ae3
--- /dev/null
+++ b/test/numerics/rand/rand.device/entropy.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// double entropy() const;
+
+#include <random>
+#include <cassert>
+
+
+int main()
+{
+    std::random_device r;
+    double e = r.entropy();
+}
diff --git a/test/numerics/rand/rand.device/eval.pass.cpp b/test/numerics/rand/rand.device/eval.pass.cpp
new file mode 100644
index 0000000..40d0735
--- /dev/null
+++ b/test/numerics/rand/rand.device/eval.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::random_device r;
+    std::random_device::result_type e = r();
+}
diff --git a/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp b/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
new file mode 100644
index 0000000..263be42
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution& operator=(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::bernoulli_distribution D;
+    D d1(0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
new file mode 100644
index 0000000..085e9d1
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::bernoulli_distribution D;
+    D d1(0.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
new file mode 100644
index 0000000..46b5bfd
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d;
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d(0);
+        assert(d.p() == 0);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d(0.75);
+        assert(d.p() == 0.75);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
new file mode 100644
index 0000000..8ac0069
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.p() == 0.25);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
new file mode 100644
index 0000000..e24378c
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bool operator=(const bernoulli_distribution& x,
+//                const bernoulli_distribution& y);
+// bool operator!(const bernoulli_distribution& x,
+//                const bernoulli_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.25);
+        D d2(.25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.28);
+        D d2(.25);
+        assert(d1 != d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
new file mode 100644
index 0000000..09a1850
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(.75);
+        int count = 0;
+        for (int i = 0; i < 10000; ++i)
+        {
+            bool u = d(g);
+            if (u)
+                ++count;
+        }
+        assert(count > 7400);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
new file mode 100644
index 0000000..c998001
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(.75);
+        P p(.25);
+        int count = 0;
+        for (int i = 0; i < 10000; ++i)
+        {
+            bool u = d(g, p);
+            if (u)
+                ++count;
+        }
+        assert(count < 2600);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
new file mode 100644
index 0000000..021eb0e
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
new file mode 100644
index 0000000..d40ee7d
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const bernoulli_distribution& x);
+// 
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            bernoulli_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.25);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
new file mode 100644
index 0000000..a821a11
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d(.25);
+        assert(d.max() == true);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
new file mode 100644
index 0000000..8a1987d
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d(.5);
+        assert(d.min() == false);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
new file mode 100644
index 0000000..c2accdb
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p0(.7);
+        param_type p;
+        p = p0;
+        assert(p.p() == .7);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
new file mode 100644
index 0000000..88914e7
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p0(.125);
+        param_type p = p0;
+        assert(p.p() == .125);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
new file mode 100644
index 0000000..591b316
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p(0.25);
+        assert(p.p() == 0.25);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
new file mode 100644
index 0000000..b628820
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
new file mode 100644
index 0000000..5396141
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
new file mode 100644
index 0000000..57f20f0
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
new file mode 100644
index 0000000..27801f1
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, bool>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
new file mode 100644
index 0000000..69ed2f1
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution& operator=(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_int_distribution<long> D;
+    D d1(2, 5);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
new file mode 100644
index 0000000..be31be2
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_int_distribution<long> D;
+    D d1(2, 5);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
new file mode 100644
index 0000000..05d55a4
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(IntType a = 0,
+//                                   IntType b = numeric_limits<IntType>::max());
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == std::numeric_limits<int>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(-6);
+        assert(d.a() == -6);
+        assert(d.b() == std::numeric_limits<int>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(-6, 106);
+        assert(d.a() == -6);
+        assert(d.b() == 106);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
new file mode 100644
index 0000000..d6bfeb3
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.a() == 3);
+        assert(d.b() == 8);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
new file mode 100644
index 0000000..54cabbe
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// bool operator=(const uniform_int_distribution& x,
+//                const uniform_int_distribution& y);
+// bool operator!(const uniform_int_distribution& x,
+//                const uniform_int_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 9);
+        assert(d1 != d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
new file mode 100644
index 0000000..1c1c7ab
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(-6, 106);
+        for (int i = 0; i < 10000; ++i)
+        {
+            int u = d(g);
+            assert(-6 <= u && u <= 106);
+        }
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
new file mode 100644
index 0000000..f72b471
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(-6, 106);
+        P p(-10, 20);
+        for (int i = 0; i < 10000; ++i)
+        {
+            int u = d(g, p);
+            assert(-10 <= u && u <= 20);
+        }
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
new file mode 100644
index 0000000..cbf4ce3
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
new file mode 100644
index 0000000..ef624a3
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const uniform_int_distribution& x);
+// 
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            uniform_int_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
new file mode 100644
index 0000000..db110b3
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(3, 8);
+        assert(d.max() == 8);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
new file mode 100644
index 0000000..4e1023c
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(3, 8);
+        assert(d.min() == 3);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
new file mode 100644
index 0000000..012ced8
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p;
+        p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
new file mode 100644
index 0000000..5c458be
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
new file mode 100644
index 0000000..ad02958
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == std::numeric_limits<long>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p(5);
+        assert(p.a() == 5);
+        assert(p.b() == std::numeric_limits<long>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p(5, 10);
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
new file mode 100644
index 0000000..7553dc2
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(5, 10);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(6, 10);
+        assert(p1 != p2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
new file mode 100644
index 0000000..2351ee4
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
new file mode 100644
index 0000000..56dbfdd
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(6, 7);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
new file mode 100644
index 0000000..34bcd94
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
new file mode 100644
index 0000000..8631e30
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution& operator=(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_real_distribution<float> D;
+    D d1(2, 5);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
new file mode 100644
index 0000000..c4a6439
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_real_distribution<float> D;
+    D d1(2, 5);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
new file mode 100644
index 0000000..c4e3ca1
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(RealType a = 0,
+//                                    RealType b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(-6);
+        assert(d.a() == -6);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(-6, 106);
+        assert(d.a() == -6);
+        assert(d.b() == 106);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
new file mode 100644
index 0000000..50643e4
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3.5, 8);
+        D d(p);
+        assert(d.a() == 3.5);
+        assert(d.b() == 8);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
new file mode 100644
index 0000000..1cb2a23
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// bool operator=(const uniform_real_distribution& x,
+//                const uniform_real_distribution& y);
+// bool operator!(const uniform_real_distribution& x,
+//                const uniform_real_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8.1);
+        assert(d1 != d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
new file mode 100644
index 0000000..95923be
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <iostream>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(-6.5, 106.75);
+        for (int i = 0; i < 10000; ++i)
+        {
+            D::result_type u = d(g);
+            assert(d.min() <= u && u < d.max());
+        }
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
new file mode 100644
index 0000000..7801c31
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(-6, 106);
+        P p(-10, 20);
+        for (int i = 0; i < 10000; ++i)
+        {
+            int u = d(g, p);
+            assert(p.a() <= u && u < p.b());
+        }
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
new file mode 100644
index 0000000..f5cf4d3
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
new file mode 100644
index 0000000..b4e3438
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const uniform_real_distribution& x);
+// 
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            uniform_real_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
new file mode 100644
index 0000000..51a3e96
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(3, 8);
+        assert(d.max() == 8);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
new file mode 100644
index 0000000..1764b5d
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(3, 8);
+        assert(d.min() == 3);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
new file mode 100644
index 0000000..e65886b
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p;
+        p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
new file mode 100644
index 0000000..c865792
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
new file mode 100644
index 0000000..e9c064e
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p(5);
+        assert(p.a() == 5);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p(5, 10);
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
new file mode 100644
index 0000000..3d2a81d
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(5, 10);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(6, 10);
+        assert(p1 != p2);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
new file mode 100644
index 0000000..f14e23b
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
new file mode 100644
index 0000000..2501c8b
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(6, 7);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
new file mode 100644
index 0000000..f5c459e
--- /dev/null
+++ b/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp b/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
new file mode 100644
index 0000000..8a02973
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine& operator=(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> E;
+    E e1;
+    E e2;
+    assert(e1 == e2);
+    e1();
+    e2 = e1;
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
new file mode 100644
index 0000000..f4dd8c3
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> E;
+    E e1;
+    E e2 = e1;
+    assert(e1 == e2);
+    e1();
+    e2();
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..d91ecbb
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// explicit linear_congruential_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+    // c % m != 0 && s % m != 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+}
+
+template <class T>
+void
+test2()
+{
+    // c % m != 0 && s % m == 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+        E e(0);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+        E e(4);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+}
+
+template <class T>
+void
+test3()
+{
+    // c % m == 0 && s % m != 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+        E e(3);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "3");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "3");
+    }
+}
+
+template <class T>
+void
+test4()
+{
+    // c % m == 0 && s % m == 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+        E e(0);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+        E e(8);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+}
+
+int main()
+{
+    test1<unsigned short>();
+    test1<unsigned int>();
+    test1<unsigned long>();
+    test1<unsigned long long>();
+
+    test2<unsigned short>();
+    test2<unsigned int>();
+    test2<unsigned long>();
+    test2<unsigned long long>();
+
+    test3<unsigned short>();
+    test3<unsigned int>();
+    test3<unsigned long>();
+    test3<unsigned long long>();
+
+    test4<unsigned short>();
+    test4<unsigned int>();
+    test4<unsigned long>();
+    test4<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..3e25606
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template<class Sseq> explicit linear_congruential_engine(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned a[] = {3, 5, 7};
+        std::seed_seq sseq(a, a+3);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e1(sseq);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+        assert(e1 == e2);
+    }
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
new file mode 100644
index 0000000..175ee88
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine();
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> LCE;
+    typedef typename LCE::result_type result_type;
+    LCE e1;
+    LCE e2;
+    e2.seed();
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
new file mode 100644
index 0000000..678d6f0
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+rand0()
+{
+    typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+    E e;
+    e.discard(9999);
+    assert(e() == 1043618065);
+}
+
+template <class T>
+void
+rand()
+{
+    typedef std::linear_congruential_engine<T, 48271, 0, 2147483647> E;
+    E e;
+    e.discard(9999);
+    assert(e() == 399268537);
+}
+
+template <class T>
+void
+other()
+{
+    typedef std::linear_congruential_engine<T, 48271, 123465789, 2147483647> E;
+    E e1;
+    E e2;
+    assert(e1 == e2);
+    e1.discard(1);
+    assert(e1 != e2);
+    e2();
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    rand0<unsigned int>();
+    rand0<unsigned long>();
+    rand0<unsigned long long>();
+
+    rand<unsigned int>();
+    rand<unsigned long>();
+    rand<unsigned long long>();
+
+    other<unsigned int>();
+    other<unsigned long>();
+    other<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
new file mode 100644
index 0000000..96a01a8
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/eval.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+randu()
+{
+    typedef std::linear_congruential_engine<T, 65539, 0, 2147483648u> E;
+    E e(1);
+    assert(e() == 65539);
+    assert(e() == 393225);
+    assert(e() == 1769499);
+    assert(e() == 7077969);
+    assert(e() == 26542323);
+    assert(e() == 95552217);
+    assert(e() == 334432395);
+    assert(e() == 1146624417);
+    assert(e() == 1722371299);
+    assert(e() == 14608041);
+    assert(e() == 1766175739);
+    assert(e() == 1875647473);
+}
+
+template <class T>
+void
+minstd()
+{
+    typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+    E e(1);
+    assert(e() == 16807);
+    assert(e() == 282475249);
+    assert(e() == 1622650073);
+    assert(e() == 984943658);
+    assert(e() == 1144108930);
+    assert(e() == 470211272);
+    assert(e() == 101027544);
+    assert(e() == 1457850878);
+    assert(e() == 1458777923);
+    assert(e() == 2007237709);
+    assert(e() == 823564440);
+    assert(e() == 1115438165);
+}
+
+template <class T>
+void
+Haldir()
+{
+    typedef std::linear_congruential_engine<T, 16807, 78125, 2147483647> E;
+    E e(207560540);
+    assert(e() == 956631177);
+    assert(e() == 2037688522);
+    assert(e() == 1509348670);
+    assert(e() == 1546336451);
+    assert(e() == 429714088);
+    assert(e() == 217250280);
+}
+
+int main()
+{
+    randu<unsigned int>();
+    randu<unsigned long>();
+    randu<unsigned long long>();
+
+    minstd<unsigned int>();
+    minstd<unsigned long>();
+    minstd<unsigned long long>();
+
+    Haldir<unsigned int>();
+    Haldir<unsigned long>();
+    Haldir<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
new file mode 100644
index 0000000..5e9e5d8
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/io.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template <class charT, class traits,
+//           class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const linear_congruential_engine<UIntType, a, c, m>& x);
+// 
+// template <class charT, class traits,
+//           class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            linear_congruential_engine<UIntType, a, c, m>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::linear_congruential_engine<unsigned, 48271, 0, 2147483647> E;
+        E e1;
+        e1.discard(100);
+        std::ostringstream os;
+        os << e1;
+        std::istringstream is(os.str());
+        E e2;
+        is >> e2;
+        assert(e1 == e2);
+    }
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
new file mode 100644
index 0000000..adcc8a2
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_same<
+        typename std::linear_congruential_engine<T, 0, 0, 0>::result_type,
+        T>::value), "");
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
new file mode 100644
index 0000000..bfc41c0
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1<unsigned short>();
+    test1<unsigned int>();
+    test1<unsigned long>();
+    test1<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
new file mode 100644
index 0000000..34b5732
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned a[] = {3, 5, 7};
+        std::seed_seq sseq(a, a+3);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e1;
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+        assert(e1 != e2);
+        e1.seed(sseq);
+        assert(e1 == e2);
+    }
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
new file mode 100644
index 0000000..2ff2d2c
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.lcong/values.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+//     engine characteristics
+//     static constexpr result_type multiplier = a;
+//     static constexpr result_type increment = c;
+//     static constexpr result_type modulus = m;
+//     static constexpr result_type min() { return c == 0u ? 1u: 0u;}
+//     static constexpr result_type max() { return m - 1u;}
+//     static constexpr result_type default_seed = 1u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> LCE;
+    typedef typename LCE::result_type result_type;
+    static_assert((LCE::multiplier == a), "");
+    static_assert((LCE::increment == c), "");
+    static_assert((LCE::modulus == m), "");
+    /*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/);
+    /*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/);
+    static_assert((LCE::default_seed == 1), "");
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
new file mode 100644
index 0000000..8182d96
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine& operator=(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
new file mode 100644
index 0000000..a38c119
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..c429a7b
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
@@ -0,0 +1,245 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "0 1 1812433255 1900727105 1208447044 2481403966 4042607538 337614300 "
+    "3232553940 1018809052 3202401494 1775180719 3192392114 594215549 184016991 "
+    "829906058 610491522 3879932251 3139825610 297902587 4075895579 2943625357 "
+    "3530655617 1423771745 2135928312 2891506774 1066338622 135451537 933040465 "
+    "2759011858 2273819758 3545703099 2516396728 1272276355 3172048492 "
+    "3267256201 2332199830 1975469449 392443598 1132453229 2900699076 "
+    "1998300999 3847713992 512669506 1227792182 1629110240 112303347 2142631694 "
+    "3647635483 1715036585 2508091258 1355887243 1884998310 3906360088 "
+    "952450269 3647883368 3962623343 3077504981 2023096077 3791588343 "
+    "3937487744 3455116780 1218485897 1374508007 2815569918 1367263917 "
+    "472908318 2263147545 1461547499 4126813079 2383504810 64750479 2963140275 "
+    "1709368606 4143643781 835933993 1881494649 674663333 2076403047 858036109 "
+    "1667579889 1706666497 607785554 1995775149 1941986352 3448871082 "
+    "2109910019 1474883361 1623095288 1831376534 2612738285 81681830 2204289242 "
+    "1365038485 251164610 4268495337 1805601714 1262528768 1442526919 "
+    "1675006593 965627108 646339161 499795587 840887574 380522518 3023789847 "
+    "1457635507 1947093157 2600365344 2729853143 1550618999 1390905853 "
+    "3021294812 882647559 838872117 1663880796 4222103589 2754172275 3844026123 "
+    "3199260319 4176064873 3591027019 2690294242 2978135515 3172796441 "
+    "3263669796 1451257057 1427035359 4174826006 2171992010 1537002090 "
+    "3122405306 4162452508 3271954368 3794310005 3240514581 1270412086 "
+    "3030475836 2281945856 2644171349 3109139423 4253563838 1289926431 "
+    "1396919653 733220100 2753316645 1196225013 3699575255 3569440056 "
+    "2675979228 2624079148 3463113149 863430286 623703199 2113837653 2656425919 "
+    "175981357 4271478366 4238022735 1665483419 86880610 2963435083 1830392943 "
+    "847801865 3237296945 332143967 3973606945 2671879697 2236330279 2360127810 "
+    "3283955434 203240344 4048139172 13189264 2263058814 247241371 1566765783 "
+    "3084408095 3719371299 1958375251 1985924622 1712739232 1861691451 "
+    "2644502937 2337807839 784993770 2962208780 2190810177 1523122731 "
+    "714888527 578678761 3698481324 1801168075 534650483 3390213921 3923356461 "
+    "3586009066 2059432114 52511333 1969897376 3630122061 524661135 3513619765 "
+    "563070233 501359785 477489274 658768624 938973567 1548584683 1345287459 "
+    "2488691004 3441144905 3849305094 2430000078 855172178 614463281 2092744749 "
+    "176381493 1655802051 2273888101 2474494847 3471978030 2138918303 575352373 "
+    "1658230985 1675972553 2946663114 915579339 284981499 53939948 3022598146 "
+    "1861218535 3403620774 4203516930 2360471119 3134536268 1383448498 "
+    "1307602316 3847663247 3027225131 3597251613 3186237127 725127595 "
+    "1928526954 1843386923 3560410503 54688266 1791983849 2519860352 4256389699 "
+    "2328812602 486464275 3578698363 301279829 1303654791 4181868765 971794070 "
+    "1933885487 3996807464 2144053754 4079903755 3775774765 3481760044 "
+    "1212862354 1067356423 3764189132 1609862325 2209601551 2565747501 "
+    "161962392 4045451782 2605574664 2520953090 3490240017 1082791980 44474324 "
+    "101811128 4268650669 4171338684 772375154 3920460306 2319139534 599033750 "
+    "2950874441 3373922995 1496848525 4095253594 1271943484 1498723121 "
+    "3097453329 3698082465 281869581 3148270661 3591477288 747441437 2809508504 "
+    "3896107498 303747862 2368081624 1844217645 886825352 287949781 1444561207 "
+    "2512101757 2062331723 741720931 1383797313 3876746355 2041045348 "
+    "2627599118 1124169970 200524822 3484820454 55883666 1135054804 669498692 "
+    "2677215504 3097911127 1509628615 617580381 2229022193 85601568 3243896546 "
+    "3715672328 912168347 2359163500 1180347564 4243175048 2092067103 880183327 "
+    "4000664709 2045044777 3500474644 1515175520 1862207123 186628841 "
+    "3337252925 708933575 4015964629 3136815297 3314919747 2891909013 "
+    "3316567785 3944275369 3608506218 2884839110 3054055598 2707439927 "
+    "1381111877 3275487281 4292456216 2639563270 3327301876 3576924628 "
+    "721056309 2002808140 748967365 52380958 2200261692 763456477 1708381337 "
+    "2038446433 2682979402 1526413779 2211263302 3879771969 75966584 3645059271 "
+    "2985763524 4085690255 82390958 1883631385 1647521260 1598026998 3038041577 "
+    "2501913134 3279302868 1738888524 805035483 756399074 3863810982 1097797270 "
+    "1505792529 898904527 583561003 717152376 3333867738 1099456544 1663473545 "
+    "1242141229 3828627682 1966201676 1713552361 3852160017 1584965284 21695908 "
+    "1013262144 145341901 3995441263 3462066219 2239637848 1214086163 "
+    "2428868268 1650037305 1545513388 1621198806 4232947817 1823092073 "
+    "256414624 1745018809 1357102386 2055139770 3280958307 2482431613 "
+    "1664870585 859130423 4097751123 3079768369 2470211009 2984880786 "
+    "2808568948 2877071923 1984903163 302768457 1866396789 869566317 3746415787 "
+    "4169433075 3025005404 3980733379 3539207278 3953071536 876960847 "
+    "2548872156 800507464 1865466907 1273317878 3754712872 1757188269 "
+    "3229950355 3731640200 2283390608 2204990292 411873449 447423849 1852437802 "
+    "472825525 3044219944 2913114194 1859709265 4053786194 574820536 2104496732 "
+    "865469814 2438352724 4208743605 4215067542 1364015250 4139974345 "
+    "3838747005 1818502786 2914274940 1402365828 1751123528 2302578077 "
+    "2463168652 1968705496 1730700144 3023943273 1139096844 2658667767 "
+    "2063547264 705791165 1444775274 2415454225 1575664730 921044163 648101324 "
+    "1212387162 4191962054 1787702169 1888718041 1518218010 3398792842 "
+    "4079359729 149721439 750400353 2661036076 3802767886 520152586 951852508 "
+    "2939585975 1375969109 385733137 3523607459 1902438415 4250996086 "
+    "2712727066 484493674 3932107461 1428488210 1764242548 3424801055 "
+    "4004904451 2226862072 2393366939 3609584727 3614444319 317349896 "
+    "3826527525 204023804 981902443 3356042039 3051207045 1869902661 561831895 "
+    "3706675415 1527687593 1227610446 2596341042 3191717368 3269246891 "
+    "557877074 4062070629 3052520266 3772487029 400039836 3195205275 4085394797 "
+    "1655557239 1345770144 2864727192 449281238 73189507 528365765 2727400656 "
+    "247880434 2408277395 777039183 2210179398 1088433648 2124356402 1555630141 "
+    "604790219 195012151 3312518356 923728373 3999251660 3313059535 3478133921 "
+    "3395026960 383464614 3425869222 2446885186 4032184426 157195416 3158909476 "
+    "1663750443 2046427584 1658453076 1784483001 3146546889 1238739785 "
+    "2297306523 3472330897 2953326031 2421672215 1221694592 1588568605 "
+    "2546987845 3375168573 2137961649 3056565164 330165219 235900365 1000384800 "
+    "2697255904 579122283 3050664825 73426122 1232986102 2940571064 3076486824 "
+    "1708182873 2796363264 292154131 4280019913 1102652157 1185393592 "
+    "1494991690 4270076389 2384840717 425785147 2385321880 317514772 3926962743 "
+    "392176856 3465421709 1878853468 122662664 2958252160 1858961315 2244939588 "
+    "2361884409 2860936803 683833250 3291277128 1686857206 1112632275 "
+    "1200680507 3342928196 2677058150 939442136 3407104669 2906783932 "
+    "3668048733 2030009470 1910839172 1234925283 3575831445 123595418 "
+    "2362440495 3048484911 1796872496";
+    std::mt19937 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "0 1 6364136223846793007 13885033948157127961 "
+    "15324573939901584278 12737837167382305846 15195339788985155882 "
+    "6554113247712070460 17235932740818599105 13007415075556305955 "
+    "6585479514541334743 8274505865835507625 1718218088692873364 "
+    "10390651247454232081 12911994993614796389 3986900029987203370 "
+    "6673827651897561714 4426752746717694792 7419158062930293690 "
+    "5800047417539173618 15710773105226458059 16164512590413496893 "
+    "3438015953120274172 3483801391287623267 293704481016263807 "
+    "11580856846363212652 3489109114147636336 3391036861618673611 "
+    "8265793309278544843 7557898467821912223 11008748280761875940 "
+    "15929443707841919885 8545695347411085846 10810459396490399532 "
+    "12233244910455127352 15556950738631379285 16711543556686614082 "
+    "12362193084052127890 16520645558585805174 5163125267185202360 "
+    "405552980610370477 17567412011316060306 18195950784827697319 "
+    "7893142112162906367 11294475722810961618 7284845498332539581 "
+    "8406882439401998138 4375387785957411470 9627875716250684710 "
+    "8860968026642934661 9743109216691708518 152611520104818631 "
+    "5897430410700879663 5351672954305365323 16325991383734641720 "
+    "9695181037355459478 15420132328343498044 17772146581546890572 "
+    "12095930435311226909 3066005052193896110 11579395203346116306 "
+    "9168946227698330317 18318927644793076250 16096433325093805476 "
+    "14945900876820434843 16826760579960858105 17664119339058295604 "
+    "17844797344364136942 1071414400549507565 16688779616725465582 "
+    "3684635020921274863 12774052823168116810 17270284502989966576 "
+    "1081012692742984704 4377021575203177546 18341292555997099853 "
+    "13297939683513494274 15065725504474304333 10796297883750572804 "
+    "15233335271871291997 8767977593699151062 3360856014170688284 "
+    "7828232912764786750 15167717223619970150 9622174963375022357 "
+    "18262792478991268448 1196631425707106493 5368342740538672272 "
+    "10381091599850241237 12108437846306626340 6150860188928778248 "
+    "3342980288459577584 12715439159457051276 17996971042887275859 "
+    "9749679821487730542 17763727344608586331 16024467606290078168 "
+    "7763401887585513696 4448278918811662063 16947956613780322662 "
+    "15144807360840708645 3878082612940188435 10709780449699561405 "
+    "1649555943517500922 3206645931693769562 12562913950237146427 "
+    "237213339742767727 12987800257476421358 1653669854585203688 "
+    "3485900643226898485 13961759114404652223 5243794832751327611 "
+    "10337687908642742498 16946139522050041809 16716562961992396380 "
+    "4275124606042261542 4055100795824867618 6424268654905981295 "
+    "3424516503413156556 2670380025813203539 10750762735193959951 "
+    "8790031149370411970 4021216986392972993 12076090355041998696 "
+    "14407920322903159838 10653597737935867030 15483225617438352002 "
+    "2497775263858626604 12295882369431088188 14256043521530136935 "
+    "2687322778627883798 3419797801078863201 8786888481486602641 "
+    "445698423634900693 9597067954623467255 7101345576557603992 "
+    "1498579197046783597 10403325187679734962 2464586980321053562 "
+    "2022012026329844477 10802281218030350853 6628929099856200904 "
+    "6828177972863192803 8589868113309334601 5245595233272009016 "
+    "5335692004673212054 4515133017699498525 15966447436053813932 "
+    "15199779177078162007 4190689609934804313 13003438276435994683 "
+    "8406046831313066396 10564320513686955057 12668913223662201488 "
+    "13130110932487580228 1030848205404711145 17684061609212954769 "
+    "12942207438298787911 10731611242140874687 5165052527778107352 "
+    "16323046249518133445 17119162873327029615 5754858052433703070 "
+    "3864761150247579030 9945988334920003074 11409854727071782565 "
+    "5000838138362434817 15526574143469400487 18094554078711846524 "
+    "5576294272011007484 3478525338408894755 11392694223389544658 "
+    "4692963068671452476 4459301637730340710 9699395817392066460 "
+    "14644636990626292085 18065377773424192622 5217202490849387226 "
+    "16175595974171756081 2109372019589047677 1624752883142646445 "
+    "13462209973053735966 12082930933973802402 1568864426788967895 "
+    "17047994306870001795 10556833209957537593 955604103878351641 "
+    "9062985603395234592 9757612676622840969 1767246562613391916 "
+    "9752598821733361274 7499745701633625047 7824811626141302622 "
+    "15819064077972391284 5660565551854829485 17645390577243129343 "
+    "7343780801046581776 2233358068547689666 8716657172695403744 "
+    "9129027798969787220 334709674395230649 2063182499026924878 "
+    "13089071159640936832 1765917316143960741 17552378408917656269 "
+    "3917018959478722819 15626740210483166037 1645962609209923821 "
+    "12277169606472643961 14545894350924442736 11485249378718653961 "
+    "9205208816702766530 10967561305613932827 3105992977398681914 "
+    "2125140299311648264 11619505070220308543 5030167448920096401 "
+    "4248170446421798953 16184577688118775567 9240607582885304823 "
+    "11838996733938359277 415426114101983968 14340734742548675134 "
+    "4124085748228276376 17686494750190224280 9472996569628985376 "
+    "1207013222233148636 3031046462562068367 45068538181330439 "
+    "8678647417835301152 10693327126492781235 3058899219097846020 "
+    "18377730418355022492 10269941972656742364 15986476992758938864 "
+    "14575856764093007010 14749682846448398393 1042926396621439263 "
+    "12184905641567868001 3518848236485931862 6718580865438347534 "
+    "6319395993260741012 2855168874111910691 2482146419106261786 "
+    "17290238774162848390 8071397865265268054 15873003794708011585 "
+    "14422764926380465297 14140979091525022882 3573480287238168646 "
+    "1525896111244666696 7537826952717918371 10482908122538761078 "
+    "17003233041653857 9473838740924911883 8438240966750123668 "
+    "10697754962581554225 15048771265786776312 9067877678399943713 "
+    "3399555692325948067 6150260207049997483 7165140289246675175 "
+    "14816202987105583988 4753550992948864498 10549400354582510015 "
+    "13212062554023586370 1585477630313819722 476999696494664205 "
+    "3208739183359199317 16011681780347380478 8149150693959772807 "
+    "803412833228911773 2360961455092949929 1517204230639934662 "
+    "13863717544358808032 16792122738584967930 12742474971940259289 "
+    "1859755681395355028 1540431035241590810 3883807554140904361 "
+    "16189061625447625933 12376367376041900879 8006563585771266211 "
+    "2682617767291542421 8593924529704142157 9070391845133329273 "
+    "3557484410564396342 9301398051805853085 12632514768298643219 "
+    "227653509634201118 7247795074312488552 4939136716843120792 "
+    "6533591052147596041 1308401457054431629 17488144120120152559 "
+    "14075631579093810083 4015705597302725704 6833920126528811473 "
+    "5095302940809114298 8312250184258072842 15770605014574863643 "
+    "14091690436120485477 15763282477731738396 16394237160547425954 "
+    "5066318118328746621 13140493775100916989 6371148952471982853 "
+    "15150289760867914983 4931341382074091848 12635920082410445322 "
+    "8498109357807439006 14836776625250834986";
+    std::mt19937_64 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..fa02aff
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
@@ -0,0 +1,309 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "358595400 4166558815 2016177162 3414480257 "
+    "4027494649 3722317195 1190532340 3212207148 "
+    "3537847251 389019999 1098708832 3277907415 "
+    "1946784350 3608286140 2091419822 2227407035 "
+    "2229110723 1825348377 1276269279 314337202 "
+    "3182935337 1313150029 3118776508 3707918501 "
+    "1900972958 4054820954 3973178248 906260237 "
+    "1403942218 3139931556 2807126524 3940936448 "
+    "1316345796 631296613 2268418920 2914000794 "
+    "3760588399 3226216036 880155129 4183611084 "
+    "211541083 3755352858 1331383234 3036493096 "
+    "937478630 2092170412 777784402 93392729 "
+    "3644029210 1681392086 2427001226 3143870332 "
+    "3703581502 2017505388 1706274541 1049329728 "
+    "2452031492 3437261233 2581204087 1700889875 "
+    "1652573881 2127047692 3778506964 1960741508 "
+    "2739602360 3395905609 2123355622 3041272975 "
+    "784200748 3558951522 1002787860 4063320888 "
+    "1587315560 4042698976 659183308 3082256417 "
+    "2808969567 2361418535 3468698782 750700970 "
+    "2991209851 3581521382 962022878 2518967363 "
+    "1476525873 3865977235 2128790058 2380326689 "
+    "1396773405 312559410 1370621899 1154499924 "
+    "2963101919 2182689761 2071851902 1661288848 "
+    "2411351341 1362764020 1289894483 1951662807 "
+    "701821506 552267185 2356648449 3949188503 "
+    "1748307081 87795201 3718396254 4112205936 "
+    "2819888864 73923733 2800033151 839258139 "
+    "3801779069 3105962436 2111266436 1772784466 "
+    "3692264298 4148810953 3147390749 3537518553 "
+    "1695044978 1430225842 1252346204 3465285434 "
+    "3970017763 2920658411 2805151132 290569815 "
+    "3802301355 1493420394 1943029276 1667143611 "
+    "1049665988 1710824905 220168517 3997946231 "
+    "1014582791 4244598752 1147604069 2533886627 "
+    "598679964 761521020 431779255 3745982038 "
+    "768658283 3598262505 1765664789 279538641 "
+    "715144305 2371628432 2655860083 1759010423 "
+    "3568452003 1910107098 2801429529 3924547532 "
+    "3862672436 3933725740 1764550618 130893617 "
+    "1460692387 4135312761 2075529299 2880227367 "
+    "944557368 4166665482 2627749235 3732013815 "
+    "1595900818 1553312393 3529311831 3531462424 "
+    "2431328342 4075369692 1609967709 3704537555 "
+    "2067297464 397140475 920618678 2840795964 "
+    "4202512837 1286017648 7035910 1057207826 "
+    "2325188262 191593698 3697383848 3029712831 "
+    "2073681914 163454681 1329637200 290077398 "
+    "287239431 4205081522 1233889024 167173087 "
+    "3267660257 3406068803 2382354609 1680046927 "
+    "125183503 3559536309 3208900974 2912148541 "
+    "2882879316 1937001086 2919729069 892928802 "
+    "4141691387 2507406586 855548593 3418647837 "
+    "4035646154 2410275591 248715645 3180757482 "
+    "1880770722 362912336 2964920095 2319904154 "
+    "1493655850 4240733030 1834485846 1696040454 "
+    "3329457927 1865824694 847759208 1587231623 "
+    "3757294772 1161601118 3630323833 3007722125 "
+    "3726418007 2124238171 1205345 172659797 "
+    "3040354211 885213338 1857049013 447922412 "
+    "719906299 1370059380 1922204800 3960090489 "
+    "1658822644 1529626863 1565927273 3537718771 "
+    "2733237258 2180221377 921910745 2144937687 "
+    "1727603895 1315635304 4023867791 2401834107 "
+    "808854185 2408824497 343935326 185237544 "
+    "746732759 2641236122 4283215329 743609415 "
+    "1134726665 3892851319 1302851263 3473445597 "
+    "1326817414 2702766508 1943179285 4025685468 "
+    "932896770 199392138 2787362875 3450501893 "
+    "3351567147 2461286528 2227605848 2993751114 "
+    "3988215720 1320573368 2866560199 4153194990 "
+    "3007120042 3260751955 3171763740 2111121243 "
+    "3962825228 102681859 3368179132 802089147 "
+    "4029273561 424939445 4178414761 2592125109 "
+    "1960801088 2967746406 310701990 2364200202 "
+    "1320507009 3474372480 784693947 2952246664 "
+    "1891935330 2048385105 3530082191 3238151038 "
+    "3293189141 1316053288 2087004409 740799958 "
+    "1187748554 3607767334 1190185990 1408429481 "
+    "657134359 221834425 3907725865 1068016389 "
+    "1402423875 2598612116 2046886300 2345022518 "
+    "1196081924 357783981 4013683598 463491626 "
+    "3269206482 3332444286 886491955 2257342866 "
+    "475911113 833576299 2893727564 2866985145 "
+    "1413365115 2995166393 1486060436 161205225 "
+    "3181728373 3056027137 2040371876 2182305146 "
+    "3028448628 2214316977 1266227021 876938740 "
+    "276477469 752158077 2182179045 1381698878 "
+    "3424557652 666674427 968327842 2534296575 "
+    "265105940 961112540 2641188117 2319139814 "
+    "1750453329 3450138343 678025317 1477566458 "
+    "3773796420 2933993832 3326042905 4084805260 "
+    "444182455 255333481 785163068 2321290820 "
+    "2893603234 3005520266 541104079 1383277090 "
+    "2770755666 3764627833 583371929 2864949033 "
+    "1487681116 1811788361 240329486 3094213377 "
+    "958509875 2564379085 1636995945 2070894127 "
+    "2139004232 1747850055 3841512327 3325011872 "
+    "1161622604 639182193 3533652535 4022667522 "
+    "761048999 3337743670 254221568 2784956233 "
+    "2990252814 4207922787 275707208 261819597 "
+    "2071467265 4034945770 1999813410 3038921100 "
+    "2200194573 1328217451 2440612380 3862293692 "
+    "2733976812 2750523058 2920082515 3809044908 "
+    "4285231753 3131963297 3481602724 1396460739 "
+    "2011767965 2481047764 2958452120 3044188618 "
+    "2217236658 3448605566 757716104 1818279145 "
+    "2641228144 1312649639 1194087684 3845229729 "
+    "1747658356 874418803 1956637337 268670179 "
+    "2083040240 2577671381 3375334655 2587828868 "
+    "1383012799 3583445685 2594576715 3282337104 "
+    "4257972751 3440488071 3129180313 1830891395 "
+    "1594931092 2680778339 3984026324 1102770400 "
+    "2315820258 1263467048 1133254110 2400676748 "
+    "2251795328 1036154092 3313541051 2277356560 "
+    "1477696003 1417117088 3968537402 1404882202 "
+    "2011058180 4114080985 1727459502 4100235708 "
+    "2334509310 2829432554 377936301 1519324520 "
+    "3252826644 1193335837 1929125820 2165344238 "
+    "4160556243 223340988 670907625 1485396519 "
+    "936389509 3813712964 2706450987 3132506320 "
+    "875886515 557088991 2854916639 2955496008 "
+    "2881696287 265169077 3239923698 3649366121 "
+    "4072165960 1233904959 225406526 1767368993 "
+    "1894882500 2296582180 339255168 83200939 "
+    "2958376148 4100205346 1991250823 3806183082 "
+    "2691709980 2642354997 3024056146 1681065839 "
+    "3438299684 1638853652 362567001 2307868899 "
+    "988801086 1342833399 2303298376 1500039911 "
+    "765489391 4080464497 4155444368 980472018 "
+    "2026981853 3460406995 391970367 667377014 "
+    "4177754853 2657468948 3560690175 3030464357 "
+    "2948380657 1208800977 2316451404 4001932203 "
+    "1977856863 4265848271 3116200050 3037586215 "
+    "1335232764 930230766 1026089249 2482219415 "
+    "2613853154 1854543497 2909555107 3862874043 "
+    "2609355500 907364682 383900687 358164223 "
+    "232347546 2536276737 3118482806 1254103998 "
+    "2357334077 1204777304 1996643329 4046232717 "
+    "2570520290 3173323380 1201411457 2361883023 "
+    "806087062 2984143714 2355127569 864220085 "
+    "1787696713 1182652984 4200065581 100722519 "
+    "2380458669 2429592313 2618338302 1236529564 "
+    "1747130196 3711661325 1114068102 510380433 "
+    "93703089 2277774664 3220741441 1577998569 "
+    "2816701900 4206763045 2495239107 4080390459 "
+    "1307072677 20360728 1468385549 96049834 "
+    "3630657447 2809517346 3396111678 3043831060 "
+    "673178359 4256729562 1755211210 1969834535 "
+    "498315110 3717726302 1544859987 2239930949 "
+    "1595372585 294525219 3961637067 3591840665 "
+    "3324896933 2300077772 721255886 4197934760 "
+    "1468866696 2184812884 628246683 3385113037 "
+    "3041166140 3948531843 1176600829 228286131 "
+    "2447397608 712235937 3332826819 2676980703 "
+    "4019468871 1952389952 1202638254 3625447051";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::mt19937 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "17895233847644109640 14665081038668852234 15987230621890949369 "
+    "13796324649827964148 1670828176732799955 14078505147839608672 "
+    "15497470967856861790 9566640372296747182 7839811585250789315 "
+    "1350068003782415071 5639936432479386921 15925388701147119804 "
+    "17415323390466493342 3892358083553387400 13485903346102334794 "
+    "16926193162581531132 2711398308226914244 12515538113016451944 "
+    "13856492368211347055 17968472785843263993 16129117710261673051 "
+    "13041638543181171650 8985803498136324582 401118717516975186 "
+    "7221524024767248666 13502820261231663498 8665119664667372350 "
+    "4506836866186850029 14762924585995667460 7305266389803732087 "
+    "9135600275824854713 8421320656548229332 14585303533697565624 "
+    "13062167967956981222 15285580395823625260 17451830328116466708 "
+    "17363259891080004456 13238190509560321740 10142215382802200927 "
+    "3224236118694175902 15382517208605932923 10818882444738383326 "
+    "16604245792882032433 10223425285179753002 1342432445403828765 "
+    "4958539418185107403 9374581143772158175 7135181273441366910 "
+    "5853026900476841261 8382327930174454355 2371969498930803266 "
+    "16961635468480846337 377077518789053577 17661790013255465310 "
+    "317500018453124832 3604586262706855295 13340007089026272125 "
+    "7614051306438090372 17819007364113857386 15193526497275633437 "
+    "6142773218979108210 14883287611587512668 12544132362002344419 "
+    "1247987855434921372 6414191755211735979 7160327288923375132 "
+    "7347937017206972868 17171048313531629893 18230412825496997383 "
+    "10882960195884354661 3270707876715241884 16088870345045208503 "
+    "15454419782166694763 1200609322828949525 10186066554418904177 "
+    "7554892242763986291 8203847521335919011 16855803304338943001 "
+    "16895223408596071476 562183806034700250 17761033068687156643 "
+    "12370482348384718931 17895691979506634040 16028877286272943475 "
+    "6671425930002400146 15167515621662197335 17503579548680921174 "
+    "15910867647138768989 1705705354110203064 12201125760909412022 "
+    "5523403744441352645 4540673037752294406 822888669354888870 "
+    "13012517529113958824 702032511346794490 1245872939048413008 "
+    "18060687614291143943 718002942670251776 14628954120078526945 "
+    "7215746609592654001 15288092036204733967 12507582747898016110 "
+    "8319356319569362772 3835100005166188461 10769229288786702843 "
+    "14682980657311687345 10352054841727718090 13661249361946024317 "
+    "1558696616315734178 9963912474249467679 18213809676410642730 "
+    "7284438284457478230 8013656044128665351 6817107912809760616 "
+    "4989038816564331700 12918068165960947833 9123533477086273623 "
+    "741568181450204257 3801962339733348259 1923812112542486965 "
+    "5884360231397942779 17008459141377852544 6569697353326895092 "
+    "15194386425456240489 9363979514988323850 9212437218544795097 "
+    "5650610605870621879 10315798944006232463 10345822437227504297 "
+    "795589193815296350 11344022765750598871 3193778122705907169 "
+    "16719669104430190089 14918335244853046975 11608293761910939782 "
+    "17290187430985633813 856382712722415618 14819792788008454203 "
+    "10571145147196955435 12858063129221173592 5671819431516788648 "
+    "17837836658827607239 14004823010100183722 9067196699747632668 "
+    "441015230260308492 3444946658209715644 1825101023084664281 "
+    "11133092574473850025 12746373758552339264 10154162549097295782 "
+    "14922316177042921089 12679802872389794491 8797747037480461410 "
+    "13907752811248535439 5652405835046458389 3181711594575177977 "
+    "15495242712294857418 6049158560807439366 952771601159099159 "
+    "4587095466254740009 11160954054611782211 10071795025240457628 "
+    "1536670498623767300 1990681379653546894 14312739227381277138 "
+    "9695213786215402291 3580182943401628617 12313607438786545484 "
+    "12864141705426648443 692371170805382036 13125536612285239925 "
+    "9372929234002877092 9510419002221032820 3766423210161674061 "
+    "3230494342413727261 5934351496112072933 2863344864469097044 "
+    "10884720908958139042 4127946927340597780 9960629658622711061 "
+    "14818231351611083857 6346099615454582885 12601407558879514692 "
+    "17544105005554819865 1096648950913019831 9969868157190185788 "
+    "12908611252828823970 5941129863397152719 16168953427117105234 "
+    "12304862402025196697 7781571759256122972 13289545261301048078 "
+    "11013924305579914035 8894422550580466537 7506958826675805512 "
+    "14280817252893250439 2745266616282182732 17277225453205013047 "
+    "14335499905842065319 11961295941780577536 18072890757248426766 "
+    "1124506606842606920 17329960125355005185 13052066741624159010 "
+    "5704650516221677069 16588425097127709212 11813406583737887980 "
+    "16359723311775411283 13451679937172566665 5997753207634594468 "
+    "10656019008205694109 13074690560123889048 14811648124990806194 "
+    "7809449463531558024 5637787273252434288 16515135932856030468 "
+    "3755600163640125044 1153929634172103321 11071014283313196016 "
+    "11114640359080035583 15390782025450330559 14097530518721927499 "
+    "14776783751481098767 7863618667181998233 11513855295425132436 "
+    "4736362806980864724 5426549653049482466 10310828122060887518 "
+    "4450247941008370560 9781171949844602811 6086471549040450051 "
+    "6033923116291003194 17669843285681524740 17610378273478865070 "
+    "12152320288002263294 6525449125788834221 5125338396312613396 "
+    "9300082688721166268 959242243476884691 6379729471368150249 "
+    "16379772457647614853 13454012201619761707 2392678998182524851 "
+    "12693758700673471007 1138892516507202079 15673908144065302514 "
+    "5299581449349386824 7590792025124859454 9863745357571267780 "
+    "357345312340746112 17610247870912740564 16347431861769737095 "
+    "11348828299228888092 7220122803951857490 7038822841708464676 "
+    "9912221445023094105 5767425533670320190 6442622362743049032 "
+    "17525461567869579503 4211095256108567696 14862334876401617373 "
+    "2866362449624104511 11413742225973279461 13015745308569358847 "
+    "5191760666536228849 17188167935010684492 18321678815621002079 "
+    "13046333455321624690 3995310719038261500 10661051209947341089 "
+    "7965203671238327266 16590917686161852835 3897101637344795372 "
+    "1538303624766151695 10893225639252940698 5386335660311332214 "
+    "5174479122000384061 17378437193516866561 13629320139302700770 "
+    "10144210341964027265 12816799659000064406 3711797003976467729 "
+    "5079455890584507977 432599929275804205 10435019529328454317 "
+    "5310854040535477246 15941464006450157396 2192067269367387270 "
+    "9782967689631091633 6777452250210540865 18067909703113078220 "
+    "17525143578810667971 87448662189824165 412530897284614413 "
+    "12066785122245373863 13073154860645125438 18282514257379582711 "
+    "8460374908111578570 15967512883067334502 9620430172798103891 "
+    "1264976185047610409 15426838192579528907 9878758812321441445 "
+    "18029992505662864846 9383699886128308360 14538949787806484635 "
+    "16958815135940772668 980481467951972605 3059030058898313960 "
+    "11497544574740915907 8385450996898478663 15571176518627282350";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::mt19937_64 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
new file mode 100644
index 0000000..1c1d5ba
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e1;
+    std::mt19937 e2(std::mt19937::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 3499211612u);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e1;
+    std::mt19937_64 e2(std::mt19937_64::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 14514284786278117030ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
new file mode 100644
index 0000000..0aaa9cd
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e1;
+    std::mt19937 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e1;
+    std::mt19937_64 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
new file mode 100644
index 0000000..e744aa9
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/eval.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e;
+    assert(e() == 3499211612u);
+    assert(e() == 581869302u);
+    assert(e() == 3890346734u);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e;
+    assert(e() == 14514284786278117030ull);
+    assert(e() == 4620546740167642908ull);
+    assert(e() == 13109570281517897720ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
new file mode 100644
index 0000000..f40fc0d
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/io.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+// 
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
new file mode 100644
index 0000000..7368b88
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/result_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::mt19937::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::mt19937_64::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
new file mode 100644
index 0000000..bdd5476
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::mt19937 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::mt19937_64 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
new file mode 100644
index 0000000..f00e38a
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::mt19937 e1;
+    std::mt19937 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::mt19937_64 e1;
+    std::mt19937_64 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
new file mode 100644
index 0000000..9fcab2b
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+// 
+//     // engine characteristics
+//     static constexpr size_t word_size = w;
+//     static constexpr size_t state_size = n;
+//     static constexpr size_t shift_size = m;
+//     static constexpr size_t mask_bits = r;
+//     static constexpr result_type xor_mask = a;
+//     static constexpr size_t tempering_u = u;
+//     static constexpr result_type tempering_d = d;
+//     static constexpr size_t tempering_s = s;
+//     static constexpr result_type tempering_b = b;
+//     static constexpr size_t tempering_t = t;
+//     static constexpr result_type tempering_c = c;
+//     static constexpr size_t tempering_l = l;
+//     static constexpr result_type initialization_multiplier = f;
+//     static constexpr result_type min () { return 0; }
+//     static constexpr result_type max() { return 2^w - 1; }
+//     static constexpr result_type default_seed = 5489u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    static_assert((E::word_size == 32), "");
+    static_assert((E::state_size == 624), "");
+    static_assert((E::shift_size == 397), "");
+    static_assert((E::mask_bits == 31), "");
+    static_assert((E::xor_mask == 0x9908b0df), "");
+    static_assert((E::tempering_u == 11), "");
+    static_assert((E::tempering_d == 0xffffffff), "");
+    static_assert((E::tempering_s == 7), "");
+    static_assert((E::tempering_b == 0x9d2c5680), "");
+    static_assert((E::tempering_t == 15), "");
+    static_assert((E::tempering_c == 0xefc60000), "");
+    static_assert((E::tempering_l == 18), "");
+    static_assert((E::initialization_multiplier == 1812433253), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+    static_assert((E::default_seed == 5489u), "");
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    static_assert((E::word_size == 64), "");
+    static_assert((E::state_size == 312), "");
+    static_assert((E::shift_size == 156), "");
+    static_assert((E::mask_bits == 31), "");
+    static_assert((E::xor_mask == 0xb5026f5aa96619e9ull), "");
+    static_assert((E::tempering_u == 29), "");
+    static_assert((E::tempering_d == 0x5555555555555555ull), "");
+    static_assert((E::tempering_s == 17), "");
+    static_assert((E::tempering_b == 0x71d67fffeda60000ull), "");
+    static_assert((E::tempering_t == 37), "");
+    static_assert((E::tempering_c == 0xfff7eee000000000ull), "");
+    static_assert((E::tempering_l == 43), "");
+    static_assert((E::initialization_multiplier == 6364136223846793005ull), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+    static_assert((E::default_seed == 5489u), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
new file mode 100644
index 0000000..4b5de2a
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine& operator=(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
new file mode 100644
index 0000000..a6ece1f
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..260eaef
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0";
+    std::ranlux24_base e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0";
+    std::ranlux48_base e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..44261a0
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux24_base e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux48_base e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
new file mode 100644
index 0000000..7603f4f
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e1;
+    std::ranlux24_base e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e1;
+    std::ranlux48_base e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
new file mode 100644
index 0000000..67fe56c
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e1;
+    std::ranlux24_base e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e1;
+    std::ranlux48_base e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
new file mode 100644
index 0000000..1e986ab
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e;
+    assert(e() == 15039276u);
+    assert(e() == 16323925u);
+    assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e;
+    assert(e() == 23459059301164ull);
+    assert(e() == 28639057539807ull);
+    assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
new file mode 100644
index 0000000..1183025
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t s, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const subtract_with_carry_engine<UIntType, w, s, r>& x);
+// 
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t s, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
new file mode 100644
index 0000000..8284c7d
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::ranlux24_base::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::ranlux48_base::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
new file mode 100644
index 0000000..06d252d
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux24_base E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux48_base E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
new file mode 100644
index 0000000..ecf013e
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux24_base e1;
+    std::ranlux24_base e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux48_base e1;
+    std::ranlux48_base e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp b/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
new file mode 100644
index 0000000..8e33725
--- /dev/null
+++ b/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+// 
+//     // engine characteristics
+//     static constexpr size_t word_size = w;
+//     static constexpr size_t short_lag = s;
+//     static constexpr size_t long_lag = r;
+//     static constexpr result_type min() { return 0; }
+//     static constexpr result_type max() { return m-1; }
+//     static constexpr result_type default_seed = 19780503u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    static_assert((E::word_size == 24), "");
+    static_assert((E::short_lag == 10), "");
+    static_assert((E::long_lag == 24), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+    static_assert((E::default_seed == 19780503u), "");
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    static_assert((E::word_size == 48), "");
+    static_assert((E::short_lag == 5), "");
+    static_assert((E::long_lag == 12), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+    static_assert((E::default_seed == 19780503u), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/test/numerics/rand/rand.predef/default_random_engine.pass.cpp b/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
new file mode 100644
index 0000000..2d0427e
--- /dev/null
+++ b/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef minstd_rand0 default_random_engine;
+
+
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::default_random_engine e;
+    e.discard(9999);
+    assert(e() == 1043618065u);
+}
diff --git a/test/numerics/rand/rand.predef/knuth_b.pass.cpp b/test/numerics/rand/rand.predef/knuth_b.pass.cpp
new file mode 100644
index 0000000..da73d89
--- /dev/null
+++ b/test/numerics/rand/rand.predef/knuth_b.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef shuffle_order_engine<minstd_rand0, 256>                      knuth_b;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::knuth_b e;
+    e.discard(9999);
+    assert(e() == 1112339016u);
+}
diff --git a/test/numerics/rand/rand.predef/minstd_rand.pass.cpp b/test/numerics/rand/rand.predef/minstd_rand.pass.cpp
new file mode 100644
index 0000000..c79d551
--- /dev/null
+++ b/test/numerics/rand/rand.predef/minstd_rand.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+//                                                                 minstd_rand;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::minstd_rand e;
+    e.discard(9999);
+    assert(e() == 399268537u);
+}
diff --git a/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp b/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp
new file mode 100644
index 0000000..0e15d74
--- /dev/null
+++ b/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+//                                                                 minstd_rand0;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::minstd_rand0 e;
+    e.discard(9999);
+    assert(e() == 1043618065u);
+}
diff --git a/test/numerics/rand/rand.predef/mt19937.pass.cpp b/test/numerics/rand/rand.predef/mt19937.pass.cpp
new file mode 100644
index 0000000..af76ccb
--- /dev/null
+++ b/test/numerics/rand/rand.predef/mt19937.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+//                                 0x9908b0df,
+//                                 11, 0xffffffff,
+//                                 7,  0x9d2c5680,
+//                                 15, 0xefc60000,
+//                                 18, 1812433253>                      mt19937;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::mt19937 e;
+    e.discard(9999);
+    assert(e() == 4123659995u);
+}
diff --git a/test/numerics/rand/rand.predef/mt19937_64.pass.cpp b/test/numerics/rand/rand.predef/mt19937_64.pass.cpp
new file mode 100644
index 0000000..decbade
--- /dev/null
+++ b/test/numerics/rand/rand.predef/mt19937_64.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+//                                 0xb5026f5aa96619e9,
+//                                 29, 0x5555555555555555,
+//                                 17, 0x71d67fffeda60000,
+//                                 37, 0xfff7eee000000000,
+//                                 43, 6364136223846793005>          mt19937_64;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::mt19937_64 e;
+    e.discard(9999);
+    assert(e() == 9981545732273789042ull);
+}
diff --git a/test/numerics/rand/rand.predef/ranlux24.pass.cpp b/test/numerics/rand/rand.predef/ranlux24.pass.cpp
new file mode 100644
index 0000000..b1e6d91
--- /dev/null
+++ b/test/numerics/rand/rand.predef/ranlux24.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux24_base, 223, 23>                ranlux24;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux24 e;
+    e.discard(9999);
+    assert(e() == 9901578u);
+}
diff --git a/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp b/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp
new file mode 100644
index 0000000..c25b33a
--- /dev/null
+++ b/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>  ranlux24_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux24_base e;
+    e.discard(9999);
+    assert(e() == 7937952u);
+}
diff --git a/test/numerics/rand/rand.predef/ranlux48.pass.cpp b/test/numerics/rand/rand.predef/ranlux48.pass.cpp
new file mode 100644
index 0000000..d0ab41f
--- /dev/null
+++ b/test/numerics/rand/rand.predef/ranlux48.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux48_base, 389, 11>                ranlux48;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux48 e;
+    e.discard(9999);
+    assert(e() == 249142670248501ull);
+}
diff --git a/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp b/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp
new file mode 100644
index 0000000..bca1239
--- /dev/null
+++ b/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>  ranlux48_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux48_base e;
+    e.discard(9999);
+    assert(e() == 61839128582725ull);
+}
diff --git a/test/numerics/rand/rand.req/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp b/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.synopsis/version.pass.cpp b/test/numerics/rand/rand.synopsis/version.pass.cpp
new file mode 100644
index 0000000..acc22b6
--- /dev/null
+++ b/test/numerics/rand/rand.synopsis/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+#include <random>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.util/nothing_to_do.pass.cpp b/test/numerics/rand/rand.util/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/numerics/rand/rand.util/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp b/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
new file mode 100644
index 0000000..b6476a0
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType, size_t bits, class URNG>
+//     RealType generate_canonical(URNG& g);
+
+#include <random>
+#include <cassert>
+
+#include <iostream>
+
+int main()
+{
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, 0>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, 0>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
new file mode 100644
index 0000000..a408c2f
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+    std::seed_seq s0;
+    std::seed_seq s;
+    s = s0;
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
new file mode 100644
index 0000000..76b08c7
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+    std::seed_seq s0;
+    std::seed_seq s(s0);
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
new file mode 100644
index 0000000..18a67e4
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::seed_seq s;
+    assert(s.size() == 0);
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
new file mode 100644
index 0000000..d55fb3a
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
@@ -0,0 +1,807 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class RandomAccessIterator>
+//     void generate(RandomAccessIterator begin, RandomAccessIterator end);
+
+#include <random>
+#include <cassert>
+
+
+
+int main()
+{
+    {
+        // These numbers generated from a slightly altered version of dSFMT
+        //  http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html
+        unsigned a[] =
+        {
+            509928861u,
+            482551238u,
+            141770655u,
+            3445468037u,
+            1614807826u,
+            3110698871u,
+            809182926u,
+            2644632325u,
+            3885131857u,
+            1278630374u,
+            3648975313u,
+            1217833759u,
+            1509686260u,
+            2817190507u,
+            134525747u,
+            250267852u,
+            2559105345u,
+            2416641579u,
+            426100435u,
+            486929906u,
+            241178241u,
+            3531539379u,
+            704692991u,
+            3001633456u,
+            3990516671u,
+            2619782509u,
+            588842726u,
+            2871949673u,
+            621390331u,
+            2304055997u,
+            3809702625u,
+            2471383485u,
+            1630735687u,
+            2167939898u,
+            2070992669u,
+            2826890739u,
+            1714346061u,
+            1912761420u,
+            539780511u,
+            716119356u,
+            1342493369u,
+            1216009367u,
+            2864243850u,
+            36288867u,
+            2981095630u,
+            2480586007u,
+            1287539180u,
+            1804977887u,
+            2219960896u,
+            297158412u,
+            2839013626u,
+            1971706101u,
+            3588181149u,
+            1387242816u,
+            3713499635u,
+            3408234160u,
+            3179393218u,
+            1359207226u,
+            3119279997u,
+            2777679329u,
+            125221793u,
+            902631799u,
+            949389096u,
+            3415339313u,
+            4117407143u,
+            3119227103u,
+            1787026946u,
+            3917387257u,
+            3936044384u,
+            2242085379u,
+            1140709958u,
+            2523265662u,
+            3627073995u,
+            3604398568u,
+            1427913954u,
+            2465898599u,
+            3825653050u,
+            2090876078u,
+            232270946u,
+            3116274782u,
+            1252172657u,
+            3197497894u,
+            3983224490u,
+            1939344836u,
+            4158531887u,
+            88050086u,
+            2343094701u,
+            1067025562u,
+            3321491106u,
+            3772162169u,
+            909332669u,
+            1671671873u,
+            755193996u,
+            978524521u,
+            2164582730u,
+            1757783103u,
+            3411415001u,
+            850017018u,
+            3068762300u,
+            555996984u,
+            2404040146u,
+            3397007611u,
+            237680219u,
+            245818821u,
+            177824968u,
+            3220945682u,
+            304446762u,
+            2267298065u,
+            1878973555u,
+            3050739800u,
+            535731508u,
+            1160102565u,
+            4109066907u,
+            984269821u,
+            3681788896u,
+            60254699u,
+            3890962421u,
+            2991673698u,
+            3982271427u,
+            3514243671u,
+            1234870914u,
+            2069958363u,
+            3867828422u,
+            1847469687u,
+            503598128u,
+            967934988u,
+            289386211u,
+            393279961u,
+            835485527u,
+            3708682854u,
+            965218590u,
+            4020339834u,
+            2159101708u,
+            2575134771u,
+            376656690u,
+            3499375240u,
+            3105954900u,
+            2786692328u,
+            3458480699u,
+            1207173847u,
+            2051152535u,
+            2738812911u,
+            2954646330u,
+            2774866710u,
+            2162149150u,
+            3993372257u,
+            2868120585u,
+            3086420190u,
+            3791115537u,
+            3226697711u,
+            1818303409u,
+            4206013897u,
+            1245186807u,
+            1680347447u,
+            684800149u,
+            2372078492u,
+            2566952562u,
+            3310947940u,
+            3885964747u,
+            3270357885u,
+            2098965232u,
+            609044652u,
+            434910954u,
+            93043847u,
+            805217072u,
+            883298424u,
+            3850995479u,
+            1840717689u,
+            124278163u,
+            4250050101u,
+            2337070911u,
+            2576763405u,
+            2518189119u,
+            3059082421u,
+            1532107996u,
+            2920167825u,
+            2726963926u,
+            3951524890u,
+            1272835728u,
+            1039392592u,
+            1237920408u,
+            1996153268u,
+            647883626u,
+            4064365193u,
+            355588474u,
+            3625797533u,
+            1209959194u,
+            503163662u,
+            530295589u,
+            1668578780u,
+            969028048u,
+            2489337768u,
+            841218738u,
+            14126306u,
+            1854884627u,
+            3617055808u,
+            202224793u,
+            1744552899u,
+            1559016256u,
+            3455976027u,
+            1064269942u,
+            2990703287u,
+            1169718685u,
+            1411804743u,
+            290849805u,
+            756035681u,
+            1505272475u,
+            1426658932u,
+            16045749u,
+            3900455443u,
+            108521850u,
+            1009491914u,
+            3928801938u,
+            1022079325u,
+            3076867150u,
+            4268343543u,
+            2886814247u,
+            2005055376u,
+            1649037732u,
+            1954533894u,
+            3779223482u,
+            1093746989u,
+            2376482601u,
+            3561720470u,
+            1870836501u,
+            651953759u,
+            1504660027u,
+            2097900540u,
+            2252668945u,
+            2469849023u,
+            1986217648u,
+            2026387757u,
+            131611273u,
+            1467981299u,
+            3440588252u,
+            1916199579u,
+            959039804u,
+            2895114746u,
+            3292235117u,
+            649379239u,
+            28649189u,
+            3121113086u,
+            3829761771u,
+            1675837301u,
+            1636154723u,
+            3737794169u,
+            4082428060u,
+            1904712095u,
+            2483810990u,
+            979972563u,
+            1269082707u,
+            370986843u,
+            1233170438u,
+            3008501783u,
+            3905837878u,
+            1566704758u,
+            2380919351u,
+            159980022u,
+            1334100319u,
+            2492554074u,
+            137995234u,
+            2318192908u,
+            2608964837u,
+            1061756617u,
+            2760140790u,
+            4069446576u,
+            1995030350u,
+            1037005594u,
+            3489306635u,
+            1588786838u,
+            513304862u,
+            3305490303u,
+            2264317975u,
+            3441620307u,
+            4116970950u,
+            3121104936u,
+            1889858928u,
+            2336693483u,
+            3906421686u,
+            2112501080u,
+            2916376262u,
+            2244436629u,
+            663123276u,
+            774309763u,
+            258379821u,
+            3845948150u,
+            3747409682u,
+            275936617u,
+            563064995u,
+            4049677403u,
+            2099547498u,
+            699768412u,
+            1193153383u,
+            4289059706u,
+            3228950241u,
+            1258043728u,
+            1334659727u,
+            3780523664u,
+            1150773584u,
+            2509712235u,
+            2088544320u,
+            1610096547u,
+            3486280247u,
+            1737969289u,
+            1530372860u,
+            2563496419u,
+            2535243890u,
+            998106254u,
+            816066803u,
+            1138534811u,
+            1405672211u,
+            2094652173u,
+            1516292650u,
+            2618233360u,
+            3603340340u,
+            247950637u,
+            119238855u,
+            1858201484u,
+            3459729922u,
+            157759693u,
+            8278624u,
+            3223944237u,
+            3937209237u,
+            3820737454u,
+            839194830u,
+            2385155004u,
+            3872251779u,
+            1375779033u,
+            2333521764u,
+            4025446588u,
+            3839106064u,
+            374878047u,
+            1312756310u,
+            1661068116u,
+            1321601295u,
+            4254646350u,
+            3813168945u,
+            134103711u,
+            1535586498u,
+            82369644u,
+            411323516u,
+            761969086u,
+            819179215u,
+            582595825u,
+            3212591411u,
+            665647256u,
+            2372804634u,
+            2378814089u,
+            801724318u,
+            658137482u,
+            2084329677u,
+            2512952888u,
+            1573871611u,
+            570440739u,
+            3791634131u,
+            1754412850u,
+            406040873u,
+            2576963615u,
+            535767962u,
+            1405150444u,
+            3050488583u,
+            3870648463u,
+            2201665400u,
+            178518008u,
+            1050761986u,
+            1635790851u,
+            2757604743u,
+            1194306620u,
+            3895813535u,
+            259506203u,
+            1836108753u,
+            555242075u,
+            2574778399u,
+            777988603u,
+            2306149504u,
+            2810362568u,
+            402408487u,
+            2163697780u,
+            1982851065u,
+            153191404u,
+            1346605886u,
+            197579289u,
+            3847665347u,
+            2437615293u,
+            819252195u,
+            3379927756u,
+            1375088563u,
+            2650550959u,
+            2949512074u,
+            3616578300u,
+            1616680753u,
+            1943918335u,
+            2372676669u,
+            599487215u,
+            2422499758u,
+            3164569986u,
+            594265585u,
+            667867933u,
+            2382753501u,
+            1213715652u,
+            1470661916u,
+            566771851u,
+            463440918u,
+            3056034602u,
+            4101174909u,
+            130576467u,
+            2390765932u,
+            1878895359u,
+            2047260663u,
+            3236801323u,
+            1417182786u,
+            2650291174u,
+            541535507u,
+            2050658788u,
+            1497955566u,
+            2322165653u,
+            2177087336u,
+            1286897331u,
+            1168276780u,
+            2296212785u,
+            865258239u,
+            1996766009u,
+            2012854679u,
+            1601388981u,
+            2613134235u,
+            1657591526u,
+            2928355430u,
+            3608354462u,
+            744304148u,
+            4205438799u,
+            3436255438u,
+            2852837451u,
+            3546154475u,
+            2198801660u,
+            2941229067u,
+            1725744406u,
+            1576016233u,
+            326273484u,
+            3350602572u,
+            2525026956u,
+            529269391u,
+            742537386u,
+            966948684u,
+            4207482684u,
+            1647708147u,
+            772473614u,
+            4100132656u,
+            2071821864u,
+            1304991378u,
+            2104686786u,
+            494532571u,
+            1596637043u,
+            3530310572u,
+            3844404338u,
+            311529967u,
+            2146085784u,
+            1023590767u,
+            3264294551u,
+            1868912500u,
+            1616049700u,
+            4044971489u,
+            226083499u,
+            2644402452u,
+            671262u,
+            3856282165u,
+            2788249556u,
+            2975877350u,
+            3022011519u,
+            482463024u,
+            3197313892u,
+            2458947070u,
+            213085732u,
+            3423982376u,
+            1127434251u,
+            3003351323u,
+            3859782824u,
+            1452447943u,
+            1377205388u,
+            294467710u,
+            4017757977u,
+            4176004933u,
+            1973840971u,
+            1057204069u,
+            2631053578u,
+            1518315828u,
+            1733084351u,
+            2897935365u,
+            371135589u,
+            2166429075u,
+            1316999184u,
+            917942378u,
+            4234919037u,
+            3994887147u,
+            202839671u,
+            2611806597u,
+            1763402132u,
+            2528354843u,
+            2928374144u,
+            4287461088u,
+            3374274817u,
+            2515840515u,
+            1174711579u,
+            1526125414u,
+            1328334421u,
+            1467789564u,
+            746112865u,
+            2522923249u,
+            2846786366u,
+            785624778u,
+            3640382502u,
+            699425627u,
+            2333340032u,
+            879149811u,
+            1012137370u,
+            3671295088u,
+            1115225691u,
+            2008076767u,
+            3224593008u,
+            409074767u,
+            3405081375u,
+            1732184447u,
+            4131742042u,
+            2887579728u,
+            411122719u,
+            49575303u,
+            2452487329u,
+            132404436u,
+            2634269867u,
+            628865612u,
+            2089064207u,
+            3493619675u,
+            573570698u,
+            2803401952u,
+            1846326706u,
+            2776480783u,
+            3202282367u,
+            161406647u,
+            555882857u,
+            3002347158u,
+            3646590134u,
+            3970439001u,
+            3593229755u,
+            589030935u,
+            1156189491u,
+            4233262968u,
+            1884160487u,
+            1538393768u,
+            2259575756u,
+            1419917258u,
+            658738179u,
+            2762821193u,
+            3753817926u,
+            760570680u,
+            900223123u,
+            3199204483u,
+            3152387802u,
+            3518662321u,
+            1138026800u,
+            4166103824u,
+            4256962887u,
+            3860671603u,
+            2476911454u,
+            336216996u,
+            708885235u,
+            725397672u,
+            1803116762u,
+            2785555576u,
+            101740015u,
+            4078718445u,
+            1955237214u,
+            9650972u,
+            449296169u,
+            584729435u,
+            3295180521u,
+            589654348u,
+            4256205129u,
+            3872811168u,
+            1159848257u,
+            3914402308u,
+            739056677u,
+            2654817235u,
+            2975781832u,
+            2945335776u,
+            2792662538u,
+            4124362519u,
+            1578034244u,
+            347127450u,
+            818851140u,
+            2127100315u,
+            2486499071u,
+            4198130806u,
+            1869105609u,
+            1961961717u,
+            1651285423u,
+            376774848u,
+            2681263019u,
+            1185959234u,
+            1674813864u,
+            32812913u,
+            3511671436u,
+            3250344299u,
+            2961919237u,
+            722029715u,
+            3677835234u,
+            3534013806u,
+            2896926420u,
+            2405611392u,
+            1523923100u,
+            538451356u,
+            2872548905u,
+            3122230170u,
+            337087364u,
+            2659340735u,
+            3849128055u,
+            556114376u,
+            1997152544u,
+            3761450839u,
+            3143779940u,
+            3256759779u,
+            2844565122u,
+            228442897u,
+            3589092287u,
+            786119294u,
+            4089515771u,
+            3720982051u,
+            1236422652u,
+            2002271241u,
+            98809947u,
+            1925281885u,
+            3856119646u,
+            3522402037u,
+            2119723860u,
+            3500067577u,
+            3688915105u,
+            443441159u,
+            1795715271u,
+            2772968214u,
+            921416086u,
+            4274010930u,
+            3123194886u,
+            4156595625u,
+            2153773382u,
+            1880645824u,
+            1783695477u,
+            2639075904u,
+            2369609874u,
+            2020298024u,
+            3035677150u,
+            20152938u,
+            3700162244u,
+            2301383878u,
+            704787941u,
+            1912605772u,
+            801557569u,
+            3080244537u,
+            2116665331u,
+            2452111071u,
+            3506260614u,
+            862540580u,
+            1275699972u,
+            66210903u,
+            106773917u,
+            3693457478u,
+            2402783622u,
+            1239121180u,
+            676003037u,
+            2603048829u,
+            1725001637u,
+            1220274379u,
+            24507488u,
+            903764486u,
+            4189545897u,
+            1702746631u,
+            3218068652u,
+            3306659191u,
+            790973134u,
+            1265526960u,
+            3431804268u,
+            3325211765u,
+            3605213000u,
+            2877687268u,
+            2252987926u,
+            2380945092u,
+            858624424u,
+            1002964636u,
+            1862801950u,
+            1624111941u,
+            2506763607u,
+            760658520u,
+            2734479345u,
+            3411969548u,
+            771362694u,
+            3655222003u,
+            2713412965u,
+            2617767046u,
+            1779451182u,
+            3696950253u,
+            1494085808u,
+            1423735456u,
+            800705781u,
+            3797847307u,
+            3518984231u,
+            196474988u,
+            1813335502u,
+            2243046583u,
+            2578707704u,
+            2592488572u,
+            4085007200u,
+            3609770110u,
+            2731535571u,
+            3190540952u,
+            1865257805u,
+            1804143221u,
+            3166875197u,
+            1184225570u,
+            2013135819u,
+            3678444101u,
+            2569887572u,
+            3559018477u,
+            3823772506u,
+            1537738480u,
+            713705243u,
+            792081862u,
+            1581340885u,
+            3140030205u,
+            3435723625u,
+            3093218524u,
+            3683643763u,
+            753869336u,
+            590258834u,
+            608176704u,
+            180732483u,
+            31365344u,
+            29753898u,
+            2899243456u,
+            1020423361u,
+            152655309u,
+            3809554076u,
+            2069071231u,
+            4000441303u,
+            3046501174u,
+            1897816893u,
+            1610689080u,
+            2580357110u,
+            255270539u,
+            3363490012u,
+            3711397066u,
+            3983751767u,
+            1725231855u,
+            172296475u,
+            2179003295u,
+            660196982u,
+            526538193u,
+            2137670317u,
+            2219075701u,
+            1987239722u,
+            856404486u,
+            2976933454u,
+            3678014122u,
+            2713682703u,
+            3329090001u,
+            2248358519u,
+            3254616418u,
+            1747030903u,
+            1620566606u,
+            880370315u,
+            2337236788u,
+            2883145755u
+        };
+        const int n = 768;
+        unsigned b[n] = {0};
+        unsigned v[] = {3, 5, 7};
+        const int size = sizeof(v)/sizeof(v[0]);
+        std::seed_seq s(v, v + size);
+        s.generate(b, b + n);
+        for (int i = 0; i < n; ++i)
+            assert(a[i] == b[i]);
+    }
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
new file mode 100644
index 0000000..d62d0f0
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class T>
+//     seed_seq(initializer_list<T> il);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::seed_seq s= {5, 4, 3, 2, 1};
+    assert(s.size() == 5);
+    unsigned b[5] = {0};
+    s.param(b);
+    assert(b[0] == 5);
+    assert(b[1] == 4);
+    assert(b[2] == 3);
+    assert(b[3] == 2);
+    assert(b[4] == 1);
+#endif
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
new file mode 100644
index 0000000..536d1ba
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class InputIterator>
+//     seed_seq(InputIterator begin, InputIterator end);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    unsigned a[5] = {5, 4, 3, 2, 1};
+    std::seed_seq s(a, a+5);
+    assert(s.size() == 5);
+    unsigned b[5] = {0};
+    s.param(b);
+    assert(b[0] == 5);
+    assert(b[1] == 4);
+    assert(b[2] == 3);
+    assert(b[3] == 2);
+    assert(b[4] == 1);
+}
diff --git a/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp b/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
new file mode 100644
index 0000000..091748d
--- /dev/null
+++ b/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq
+// {
+// public:
+//     // types
+//     typedef uint_least32_t result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::seed_seq::result_type, std::uint_least32_t>::value), "");
+}
diff --git a/test/strings/basic.string.hash/strings.pass.cpp b/test/strings/basic.string.hash/strings.pass.cpp
new file mode 100644
index 0000000..9697c34
--- /dev/null
+++ b/test/strings/basic.string.hash/strings.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <string>
+#include <cassert>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    std::string g1 = "1234567890";
+    std::string g2 = "1234567891";
+    T s1(g1.begin(), g1.end());
+    T s2(g2.begin(), g2.end());
+    assert(h(s1) != h(s2));
+}
+
+int main()
+{
+    test<std::string>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::u16string>();
+    test<std::u32string>();
+#endif
+    test<std::wstring>();
+}
diff --git a/test/strings/basic.string/input_iterator.h b/test/strings/basic.string/input_iterator.h
new file mode 100644
index 0000000..5d1a1b0
--- /dev/null
+++ b/test/strings/basic.string/input_iterator.h
@@ -0,0 +1,32 @@
+#ifndef INPUT_ITERATOR_H
+#define INPUT_ITERATOR_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+public:
+    typedef typename std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+#endif
diff --git a/test/strings/basic.string/string.access/at.pass.cpp b/test/strings/basic.string/string.access/at.pass.cpp
new file mode 100644
index 0000000..1e05a46
--- /dev/null
+++ b/test/strings/basic.string/string.access/at.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>
+
+// const_reference at(size_type pos) const;
+//       reference at(size_type pos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos)
+{
+    try
+    {
+        const S& cs = s;
+        assert(s.at(pos) == s[pos]);
+        assert(cs.at(pos) == cs[pos]);
+        assert(pos < cs.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos >= s.size());
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), 0);
+    test(S("123"), 0);
+    test(S("123"), 1);
+    test(S("123"), 2);
+    test(S("123"), 3);
+}
diff --git a/test/strings/basic.string/string.access/back.pass.cpp b/test/strings/basic.string/string.access/back.pass.cpp
new file mode 100644
index 0000000..a4ce3ac
--- /dev/null
+++ b/test/strings/basic.string/string.access/back.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& back() const;
+//       charT& back();
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    assert(&cs.back() == &cs[cs.size()-1]);
+    assert(&s.back() == &s[cs.size()-1]);
+    s.back() = typename S::value_type('z');
+    assert(s.back() == typename S::value_type('z'));
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.access/front.pass.cpp b/test/strings/basic.string/string.access/front.pass.cpp
new file mode 100644
index 0000000..42593bb
--- /dev/null
+++ b/test/strings/basic.string/string.access/front.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& front() const;
+//       charT& front();
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    assert(&cs.front() == &cs[0]);
+    assert(&s.front() == &s[0]);
+    s.front() = typename S::value_type('z');
+    assert(s.front() == typename S::value_type('z'));
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.access/index.pass.cpp b/test/strings/basic.string/string.access/index.pass.cpp
new file mode 100644
index 0000000..0018cc5
--- /dev/null
+++ b/test/strings/basic.string/string.access/index.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reference operator[](size_type pos) const;
+//       reference operator[](size_type pos);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    typedef std::string S;
+    S s("0123456789");
+    const S& cs = s;
+    for (S::size_type i = 0; i < cs.size(); ++i)
+    {
+        assert(s[i] == '0' + i);
+        assert(cs[i] == s[i]);
+    }
+    assert(cs[cs.size()] == '\0');
+    const S s2 = S();
+    assert(s2[0] == '\0');
+}
diff --git a/test/strings/basic.string/string.capacity/capacity.pass.cpp b/test/strings/basic.string/string.capacity/capacity.pass.cpp
new file mode 100644
index 0000000..f5fe109
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/capacity.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>
+
+// size_type capacity() const;
+
+#include <string>
+#include <cassert>
+
+#include "../test_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);
+}
diff --git a/test/strings/basic.string/string.capacity/clear.pass.cpp b/test/strings/basic.string/string.capacity/clear.pass.cpp
new file mode 100644
index 0000000..f1d1cfe
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/clear.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void clear();
+
+#include <string>
+#include <cassert>
+
+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);
+}
diff --git a/test/strings/basic.string/string.capacity/empty.pass.cpp b/test/strings/basic.string/string.capacity/empty.pass.cpp
new file mode 100644
index 0000000..0581217
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/empty.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// bool empty() const;
+
+#include <string>
+#include <cassert>
+
+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"));
+}
diff --git a/test/strings/basic.string/string.capacity/length.pass.cpp b/test/strings/basic.string/string.capacity/length.pass.cpp
new file mode 100644
index 0000000..ee9fb52
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/length.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type length() const;
+
+#include <string>
+#include <cassert>
+
+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"));
+}
diff --git a/test/strings/basic.string/string.capacity/max_size.pass.cpp b/test/strings/basic.string/string.capacity/max_size.pass.cpp
new file mode 100644
index 0000000..f0fc3bc
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/max_size.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type max_size() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    assert(s.max_size() >= s.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.capacity/reserve.pass.cpp b/test/strings/basic.string/string.capacity/reserve.pass.cpp
new file mode 100644
index 0000000..92d9123
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void reserve(size_type res_arg=0);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+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);
+    }
+}
diff --git a/test/strings/basic.string/string.capacity/resize_size.pass.cpp b/test/strings/basic.string/string.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..fc68dde
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/resize_size.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+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"));
+}
diff --git a/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
new file mode 100644
index 0000000..678252d
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+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"));
+}
diff --git a/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..ea257b2
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void shrink_to_fit();
+
+#include <string>
+#include <cassert>
+
+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);
+}
diff --git a/test/strings/basic.string/string.capacity/size.pass.cpp b/test/strings/basic.string/string.capacity/size.pass.cpp
new file mode 100644
index 0000000..90dd295
--- /dev/null
+++ b/test/strings/basic.string/string.capacity/size.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type size() const;
+
+#include <string>
+#include <cassert>
+
+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);
+}
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));
+}
diff --git a/test/strings/basic.string/string.iterators/begin.pass.cpp b/test/strings/basic.string/string.iterators/begin.pass.cpp
new file mode 100644
index 0000000..2d54de4
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/begin.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>
+
+//       iterator begin();
+// const_iterator begin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator b = s.begin();
+    typename S::const_iterator cb = cs.begin();
+    if (!s.empty())
+    {
+        assert(*b == s[0]);
+    }
+    assert(b == cb);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/cbegin.pass.cpp b/test/strings/basic.string/string.iterators/cbegin.pass.cpp
new file mode 100644
index 0000000..f794a46
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_iterator cb = s.cbegin();
+    if (!s.empty())
+    {
+        assert(*cb == s[0]);
+    }
+    assert(cb == s.begin());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/cend.pass.cpp b/test/strings/basic.string/string.iterators/cend.pass.cpp
new file mode 100644
index 0000000..5d5801f
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/cend.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_iterator ce = s.cend();
+    assert(ce == s.end());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/crbegin.pass.cpp b/test/strings/basic.string/string.iterators/crbegin.pass.cpp
new file mode 100644
index 0000000..707272f
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_reverse_iterator cb = s.crbegin();
+    if (!s.empty())
+    {
+        assert(*cb == s.back());
+    }
+    assert(cb == s.rbegin());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/crend.pass.cpp b/test/strings/basic.string/string.iterators/crend.pass.cpp
new file mode 100644
index 0000000..290854d
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/crend.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_reverse_iterator ce = s.crend();
+    assert(ce == s.rend());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/end.pass.cpp b/test/strings/basic.string/string.iterators/end.pass.cpp
new file mode 100644
index 0000000..cf43bdd
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/end.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       iterator end();
+// const_iterator end() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator e = s.end();
+    typename S::const_iterator ce = cs.end();
+    if (s.empty())
+    {
+        assert(e == s.begin());
+        assert(ce == cs.begin());
+    }
+    assert(e - s.begin() == s.size());
+    assert(ce - cs.begin() == cs.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/rbegin.pass.cpp b/test/strings/basic.string/string.iterators/rbegin.pass.cpp
new file mode 100644
index 0000000..1653136
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/rbegin.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>
+
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator b = s.rbegin();
+    typename S::const_reverse_iterator cb = cs.rbegin();
+    if (!s.empty())
+    {
+        assert(*b == s.back());
+    }
+    assert(b == cb);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.iterators/rend.pass.cpp b/test/strings/basic.string/string.iterators/rend.pass.cpp
new file mode 100644
index 0000000..5daed01
--- /dev/null
+++ b/test/strings/basic.string/string.iterators/rend.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       reverse_iterator rend();
+// const_reverse_iterator rend() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator e = s.rend();
+    typename S::const_reverse_iterator ce = cs.rend();
+    if (s.empty())
+    {
+        assert(e == s.rbegin());
+        assert(ce == cs.rbegin());
+    }
+    assert(e - s.rbegin() == s.size());
+    assert(ce - cs.rbegin() == cs.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+}
diff --git a/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp b/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/initializer_list.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/initializer_list.pass.cpp
new file mode 100644
index 0000000..134f4ff
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/initializer_list.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& append(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("123");
+        s.append({'a', 'b', 'c'});
+        assert(s == "123abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/iterator.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/iterator.pass.cpp
new file mode 100644
index 0000000..e9126a1
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/iterator.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& append(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+    s.append(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S("12345"));
+    test(S("12345"), s, s+1, S("12345A"));
+    test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S("1234567890"));
+    test(S("1234567890"), s, s+1, S("1234567890A"));
+    test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
+    test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("1234567890"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("1234567890A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345678901234567890"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345678901234567890""A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/pointer.pass.cpp
new file mode 100644
index 0000000..4d98a1f
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& append(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+    s.append(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S("12345"));
+    test(S("12345"), "12345", S("1234512345"));
+    test(S("12345"), "1234567890", S("123451234567890"));
+
+    test(S("12345678901234567890"), "", S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("1234567890123456789012345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/pointer_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/pointer_size.pass.cpp
new file mode 100644
index 0000000..4daffe8
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/pointer_size.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   append(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+    s.append(str, n);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S("12345"));
+    test(S("12345"), "12345", 5, S("1234512345"));
+    test(S("12345"), "1234567890", 10, S("123451234567890"));
+
+    test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("1234567890123456789012345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/push_back.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/push_back.pass.cpp
new file mode 100644
index 0000000..da5604e
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/push_back.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>
+
+// void push_back(charT c)
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::value_type c, S expected)
+{
+    s.push_back(c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), 'a', S(1, 'a'));
+    test(S("12345"), 'a', S("12345a"));
+    test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/size_char.pass.cpp
new file mode 100644
index 0000000..c567460
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/size_char.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   append(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+    s.append(n, c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S("12345"));
+    test(S("12345"), 1, 'a', S("12345a"));
+    test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
+
+    test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
+    test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
+    test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/string.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/string.pass.cpp
new file mode 100644
index 0000000..1e56234
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   append(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.append(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"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::append/string_size_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::append/string_size_size.pass.cpp
new file mode 100644
index 0000000..c043fb7
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::append/string_size_size.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   append(const basic_string<charT,traits>& str, size_type pos, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    try
+    {
+        s.append(str, pos, n);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S("12345"));
+    test(S("12345"), S("12345"), 2, 2, S("1234534"));
+    test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("123456789012345678906789012345"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/initializer_list.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/initializer_list.pass.cpp
new file mode 100644
index 0000000..61bab9c
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/initializer_list.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& assign(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("123");
+        s.assign({'a', 'b', 'c'});
+        assert(s == "abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/iterator.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/iterator.pass.cpp
new file mode 100644
index 0000000..b305674
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/iterator.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& assign(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+    s.assign(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S());
+    test(S("12345"), s, s+1, S("A"));
+    test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S());
+    test(S("1234567890"), s, s+1, S("A"));
+    test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S());
+    test(S("12345678901234567890"), s, s+1, S("A"));
+    test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/pointer.pass.cpp
new file mode 100644
index 0000000..62c1ce3
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& assign(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+    s.assign(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S());
+    test(S("12345"), "12345", S("12345"));
+    test(S("12345"), "1234567890", S("1234567890"));
+
+    test(S("12345678901234567890"), "", S());
+    test(S("12345678901234567890"), "12345", S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("12345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/pointer_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/pointer_size.pass.cpp
new file mode 100644
index 0000000..7e90b24
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/pointer_size.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   assign(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+    s.assign(str, n);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S());
+    test(S("12345"), "12345", 5, S("12345"));
+    test(S("12345"), "1234567890", 10, S("1234567890"));
+
+    test(S("12345678901234567890"), "", 0, S());
+    test(S("12345678901234567890"), "12345", 5, S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("12345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/rv_string.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/rv_string.pass.cpp
new file mode 100644
index 0000000..e62152c
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/rv_string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   assign(basic_string<charT,traits>&& str);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.assign(std::move(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());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/size_char.pass.cpp
new file mode 100644
index 0000000..eb4eaad
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/size_char.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   assign(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+    s.assign(n, c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S());
+    test(S("12345"), 1, 'a', S(1, 'a'));
+    test(S("12345"), 10, 'a', S(10, 'a'));
+
+    test(S("12345678901234567890"), 0, 'a', S());
+    test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+    test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/string.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/string.pass.cpp
new file mode 100644
index 0000000..d9dccb3
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   assign(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.assign(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());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::assign/string_size_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::assign/string_size_size.pass.cpp
new file mode 100644
index 0000000..d5bfc39
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::assign/string_size_size.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   assign(const basic_string<charT,traits>& str, size_type pos, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    try
+    {
+        s.assign(str, pos, n);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S());
+    test(S("12345"), S("12345"), 2, 2, S("34"));
+    test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S());
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("6789012345"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::copy/copy.pass.cpp b/test/strings/basic.string/string.modifiers/string::copy/copy.pass.cpp
new file mode 100644
index 0000000..71c82b5
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::copy/copy.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+template <class S>
+void
+test(S str, typename S::value_type* s, typename S::size_type n,
+     typename S::size_type pos)
+{
+    try
+    {
+        const S& cs = str;
+        typename S::size_type r = cs.copy(s, n, pos);
+        assert(pos <= cs.size());
+        typename S::size_type rlen = std::min(n, cs.size() - pos);
+        assert(r == rlen);
+        for (r = 0; r < rlen; ++r)
+            assert(S::traits_type::eq(cs[pos+r], s[r]));
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    char s[50];
+    test(S(""), s, 0, 0);
+    test(S(""), s, 0, 1);
+    test(S(""), s, 1, 0);
+    test(S("abcde"), s, 0, 0);
+    test(S("abcde"), s, 0, 1);
+    test(S("abcde"), s, 0, 2);
+    test(S("abcde"), s, 0, 4);
+    test(S("abcde"), s, 0, 5);
+    test(S("abcde"), s, 0, 6);
+    test(S("abcde"), s, 1, 0);
+    test(S("abcde"), s, 1, 1);
+    test(S("abcde"), s, 1, 2);
+    test(S("abcde"), s, 1, 4);
+    test(S("abcde"), s, 1, 5);
+    test(S("abcde"), s, 2, 0);
+    test(S("abcde"), s, 2, 1);
+    test(S("abcde"), s, 2, 2);
+    test(S("abcde"), s, 2, 4);
+    test(S("abcde"), s, 4, 0);
+    test(S("abcde"), s, 4, 1);
+    test(S("abcde"), s, 4, 2);
+    test(S("abcde"), s, 5, 0);
+    test(S("abcde"), s, 5, 1);
+    test(S("abcde"), s, 6, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 1);
+    test(S("abcdefghijklmnopqrst"), s, 0, 2);
+    test(S("abcdefghijklmnopqrst"), s, 0, 10);
+    test(S("abcdefghijklmnopqrst"), s, 0, 19);
+    test(S("abcdefghijklmnopqrst"), s, 0, 20);
+    test(S("abcdefghijklmnopqrst"), s, 0, 21);
+    test(S("abcdefghijklmnopqrst"), s, 1, 0);
+    test(S("abcdefghijklmnopqrst"), s, 1, 1);
+    test(S("abcdefghijklmnopqrst"), s, 1, 2);
+    test(S("abcdefghijklmnopqrst"), s, 1, 9);
+    test(S("abcdefghijklmnopqrst"), s, 1, 18);
+    test(S("abcdefghijklmnopqrst"), s, 1, 19);
+    test(S("abcdefghijklmnopqrst"), s, 1, 20);
+    test(S("abcdefghijklmnopqrst"), s, 2, 0);
+    test(S("abcdefghijklmnopqrst"), s, 2, 1);
+    test(S("abcdefghijklmnopqrst"), s, 2, 2);
+    test(S("abcdefghijklmnopqrst"), s, 2, 9);
+    test(S("abcdefghijklmnopqrst"), s, 2, 17);
+    test(S("abcdefghijklmnopqrst"), s, 2, 18);
+    test(S("abcdefghijklmnopqrst"), s, 2, 19);
+    test(S("abcdefghijklmnopqrst"), s, 10, 0);
+    test(S("abcdefghijklmnopqrst"), s, 10, 1);
+    test(S("abcdefghijklmnopqrst"), s, 10, 2);
+    test(S("abcdefghijklmnopqrst"), s, 10, 5);
+    test(S("abcdefghijklmnopqrst"), s, 10, 9);
+    test(S("abcdefghijklmnopqrst"), s, 10, 10);
+    test(S("abcdefghijklmnopqrst"), s, 10, 11);
+    test(S("abcdefghijklmnopqrst"), s, 19, 0);
+    test(S("abcdefghijklmnopqrst"), s, 19, 1);
+    test(S("abcdefghijklmnopqrst"), s, 19, 2);
+    test(S("abcdefghijklmnopqrst"), s, 20, 0);
+    test(S("abcdefghijklmnopqrst"), s, 20, 1);
+    test(S("abcdefghijklmnopqrst"), s, 21, 0);
+}
diff --git a/test/strings/basic.string/string.modifiers/string::erase/iter.pass.cpp b/test/strings/basic.string/string.modifiers/string::erase/iter.pass.cpp
new file mode 100644
index 0000000..348ded3
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::erase/iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator p);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, S expected)
+{
+    typename S::const_iterator p = s.begin() + pos;
+    typename S::iterator i = s.erase(p);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S("abcde"), 0, S("bcde"));
+    test(S("abcde"), 1, S("acde"));
+    test(S("abcde"), 2, S("abde"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcdefghij"), 0, S("bcdefghij"));
+    test(S("abcdefghij"), 1, S("acdefghij"));
+    test(S("abcdefghij"), 5, S("abcdeghij"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::erase/iter_iter.pass.cpp b/test/strings/basic.string/string.modifiers/string::erase/iter_iter.pass.cpp
new file mode 100644
index 0000000..97c405f
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::erase/iter_iter.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::difference_type n, S expected)
+{
+    typename S::const_iterator first = s.cbegin() + pos;
+    typename S::const_iterator last = s.cbegin() + pos + n;
+    typename S::iterator i = s.erase(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::erase/pop_back.pass.cpp b/test/strings/basic.string/string.modifiers/string::erase/pop_back.pass.cpp
new file mode 100644
index 0000000..5af7784
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::erase/pop_back.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>
+
+// void pop_back();
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, S expected)
+{
+    s.pop_back();
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S("abcde"), S("abcd"));
+    test(S("abcdefghij"), S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::erase/size_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::erase/size_size.pass.cpp
new file mode 100644
index 0000000..86a7b29
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::erase/size_size.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   erase(size_type pos = 0, size_type n = npos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.erase(pos, n);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.erase(pos);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test(S s, S expected)
+{
+    s.erase();
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, 0, S(""));
+    test(S(""), 0, 1, S(""));
+    test(S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 0, 6, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 1, 5, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 2, 4, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("abcde"));
+    test(S("abcde"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 0, 11, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 1, 10, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
+
+    test(S(""), 0, S(""));
+    test(S(""), 1, S("can't happen"));
+    test(S("abcde"), 0, S(""));
+    test(S("abcde"), 1, S("a"));
+    test(S("abcde"), 2, S("ab"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcde"), 5, S("abcde"));
+    test(S("abcde"), 6, S("can't happen"));
+    test(S("abcdefghij"), 0, S(""));
+    test(S("abcdefghij"), 1, S("a"));
+    test(S("abcdefghij"), 5, S("abcde"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghij"), 10, S("abcdefghij"));
+    test(S("abcdefghij"), 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
+
+    test(S(""), S(""));
+    test(S("abcde"), S(""));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghijklmnopqrst"), S(""));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/iter_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/iter_char.pass.cpp
new file mode 100644
index 0000000..358d40e
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/iter_char.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
+{
+    bool sufficient_cap = s.size() < s.capacity();
+    typename S::difference_type pos = p - s.begin();
+    typename S::iterator i = s.insert(p, c);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+    assert(*i == c);
+    if (sufficient_cap)
+        assert(i == p);
+}
+
+int main()
+{
+    typedef std::string S;
+    S s;
+    test(s, s.begin(), '1', S("1"));
+    test(s, s.begin(), 'a', S("a1"));
+    test(s, s.end(), 'b', S("a1b"));
+    test(s, s.end()-1, 'c', S("a1cb"));
+    test(s, s.end()-2, 'd', S("a1dcb"));
+    test(s, s.end()-3, '2', S("a12dcb"));
+    test(s, s.end()-4, '3', S("a132dcb"));
+    test(s, s.end()-5, '4', S("a1432dcb"));
+    test(s, s.begin()+1, '5', S("a51432dcb"));
+    test(s, s.begin()+2, '6', S("a561432dcb"));
+    test(s, s.begin()+3, '7', S("a5671432dcb"));
+    test(s, s.begin()+4, 'A', S("a567A1432dcb"));
+    test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
+    test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/iter_initializer_list.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..ad95511
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/iter_initializer_list.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("123456");
+        std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+        assert(i - s.begin() == 3);
+        assert(s == "123abc456");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/iter_iter_iter.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..87304c6
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/iter_iter_iter.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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> 
+//   iterator insert(const_iterator p, InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+
+template <class S, class It>
+void
+test(S s, typename S::difference_type pos, It first, It last, S expected)
+{
+    typename S::const_iterator p = s.cbegin() + pos;
+    typename S::iterator i = s.insert(p, first, last);
+    assert(s.__invariants());
+    assert(i - s.begin() == pos);
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), 0, s, s, S());
+    test(S(), 0, s, s+1, S("A"));
+    test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
+    test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, s, s, S("12345"));
+    test(S("12345"), 1, s, s+1, S("1A2345"));
+    test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, s, s, S("1234567890"));
+    test(S("1234567890"), 1, s, s+1, S("1A234567890"));
+    test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, s, s+52,
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
+    test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
+    test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
+    test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
+    test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/iter_size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/iter_size_char.pass.cpp
new file mode 100644
index 0000000..89d6e5c
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/iter_size_char.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::size_type n,
+     typename S::value_type c, S expected)
+{
+    typename S::const_iterator p = s.cbegin() + pos;
+    typename S::iterator i = s.insert(p, n, c);
+    assert(s.__invariants());
+    assert(i - s.begin() == pos);
+    assert(s == expected);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/size_pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/size_pointer.pass.cpp
new file mode 100644
index 0000000..a36e42e
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/size_pointer.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   insert(size_type pos, const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, "", S(""));
+    test(S(""), 0, "12345", S("12345"));
+    test(S(""), 0, "1234567890", S("1234567890"));
+    test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 1, "", S("can't happen"));
+    test(S(""), 1, "12345", S("can't happen"));
+    test(S(""), 1, "1234567890", S("can't happen"));
+    test(S(""), 1, "12345678901234567890", S("can't happen"));
+    test(S("abcde"), 0, "", S("abcde"));
+    test(S("abcde"), 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", S("abcde"));
+    test(S("abcde"), 1, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", S("abcde"));
+    test(S("abcde"), 2, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", S("abcde"));
+    test(S("abcde"), 4, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", S("abcde"));
+    test(S("abcde"), 5, "12345", S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", S("can't happen"));
+    test(S("abcde"), 6, "12345", S("can't happen"));
+    test(S("abcde"), 6, "1234567890", S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghij"), 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/size_pointer_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/size_pointer_size.pass.cpp
new file mode 100644
index 0000000..40460c0
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/size_pointer_size.pass.cpp
@@ -0,0 +1,363 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   insert(size_type pos, const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str,
+     typename S::size_type n, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str, n);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, "", 0, S(""));
+    test(S(""), 0, "12345", 0, S(""));
+    test(S(""), 0, "12345", 1, S("1"));
+    test(S(""), 0, "12345", 2, S("12"));
+    test(S(""), 0, "12345", 4, S("1234"));
+    test(S(""), 0, "12345", 5, S("12345"));
+    test(S(""), 0, "1234567890", 0, S(""));
+    test(S(""), 0, "1234567890", 1, S("1"));
+    test(S(""), 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 1, "", 0, S("can't happen"));
+    test(S(""), 1, "12345", 0, S("can't happen"));
+    test(S(""), 1, "12345", 1, S("can't happen"));
+    test(S(""), 1, "12345", 2, S("can't happen"));
+    test(S(""), 1, "12345", 4, S("can't happen"));
+    test(S(""), 1, "12345", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 0, S("can't happen"));
+    test(S(""), 1, "1234567890", 1, S("can't happen"));
+    test(S(""), 1, "1234567890", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 9, S("can't happen"));
+    test(S(""), 1, "1234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcde"), 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345", 2, S("a12bcde"));
+    test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345", 2, S("can't happen"));
+    test(S("abcde"), 6, "12345", 4, S("can't happen"));
+    test(S("abcde"), 6, "12345", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/size_size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/size_size_char.pass.cpp
new file mode 100644
index 0000000..280789a
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/size_size_char.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   insert(size_type pos, size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n,
+     typename S::value_type str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, n, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S(""), 1, 0, '1', S("can't happen"));
+    test(S(""), 1, 5, '1', S("can't happen"));
+    test(S(""), 1, 10, '1', S("can't happen"));
+    test(S(""), 1, 20, '1', S("can't happen"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcde"), 6, 0, '1', S("can't happen"));
+    test(S("abcde"), 6, 5, '1', S("can't happen"));
+    test(S("abcde"), 6, 10, '1', S("can't happen"));
+    test(S("abcde"), 6, 20, '1', S("can't happen"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/size_string.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/size_string.pass.cpp
new file mode 100644
index 0000000..7b2bd84
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/size_string.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   insert(size_type pos1, const basic_string& str);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), 0, S(""), S(""));
+    test(S(""), 0, S("12345"), S("12345"));
+    test(S(""), 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 1, S(""), S("can't happen"));
+    test(S(""), 1, S("12345"), S("can't happen"));
+    test(S(""), 1, S("1234567890"), S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), S("can't happen"));
+    test(S("abcde"), 0, S(""), S("abcde"));
+    test(S("abcde"), 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 1, S(""), S("abcde"));
+    test(S("abcde"), 1, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, S(""), S("abcde"));
+    test(S("abcde"), 2, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, S(""), S("abcde"));
+    test(S("abcde"), 4, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, S(""), S("abcde"));
+    test(S("abcde"), 5, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcde"), 6, S(""), S("can't happen"));
+    test(S("abcde"), 6, S("12345"), S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, S(""), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::insert/size_string_size_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::insert/size_string_size_size.pass.cpp
new file mode 100644
index 0000000..aa076a5
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::insert/size_string_size_size.pass.cpp
@@ -0,0 +1,1674 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   insert(size_type pos1, const basic_string<charT,traits,Allocator>& str, 
+//          size_type pos2, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S str, S::size_type pos2,
+     S::size_type n, S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos1, str, pos2, n);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, S(""), 0, 0, S(""));
+    test(S(""), 0, S(""), 0, 1, S(""));
+    test(S(""), 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, S("12345"), 0, 0, S(""));
+    test(S(""), 0, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, S("12345"), 1, 0, S(""));
+    test(S(""), 0, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, S("12345"), 2, 0, S(""));
+    test(S(""), 0, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, S("12345"), 4, 0, S(""));
+    test(S(""), 0, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, S("12345"), 5, 0, S(""));
+    test(S(""), 0, S("12345"), 5, 1, S(""));
+    test(S(""), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 0, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+void test1()
+{
+    test(S(""), 0, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 1, S(""), 0, 0, S("can't happen"));
+    test(S(""), 1, S(""), 0, 1, S("can't happen"));
+    test(S(""), 1, S(""), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 5, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 6, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 3, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 5, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 3, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 5, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 5, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+void test2()
+{
+    test(S(""), 1, S("1234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 5, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 9, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 11, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 4, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 8, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 10, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 2, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 4, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 5, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 6, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 2, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S(""), 0, 1, S("abcde"));
+}
+
+void test3()
+{
+    test(S("abcde"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 2, S("12abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 4, S("1234abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 6, S("12345abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 2, S("23abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 3, S("234abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 5, S("2345abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 1, S("3abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 2, S("34abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 3, S("345abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 4, S("345abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 1, S("5abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 2, S("5abcde"));
+    test(S("abcde"), 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 9, S("123456789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 8, S("23456789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 10, S("234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 1, S("6abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 2, S("67abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 4, S("6789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 5, S("67890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 6, S("67890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 1, S("0abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 2, S("0abcde"));
+    test(S("abcde"), 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+}
+
+void test4()
+{
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 2, S("a12bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 4, S("a1234bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 6, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 2, S("a23bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 3, S("a234bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 5, S("a2345bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 2, 1, S("a3bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 2, S("a34bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 3, S("a345bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 4, S("a345bcde"));
+    test(S("abcde"), 1, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 4, 1, S("a5bcde"));
+    test(S("abcde"), 1, S("12345"), 4, 2, S("a5bcde"));
+    test(S("abcde"), 1, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 1, S("a1bcde"));
+}
+
+void test5()
+{
+    test(S("abcde"), 1, S("1234567890"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 8, S("a23456789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 10, S("a234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 1, S("a6bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 2, S("a67bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 4, S("a6789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 5, S("a67890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 6, S("a67890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 1, S("a0bcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 2, S("a0bcde"));
+    test(S("abcde"), 1, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 1, S("a0bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 2, S("a0bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, S("12345"), 0, 0, S("abcde"));
+}
+
+void test6()
+{
+    test(S("abcde"), 2, S("12345"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345"), 0, 2, S("ab12cde"));
+    test(S("abcde"), 2, S("12345"), 0, 4, S("ab1234cde"));
+    test(S("abcde"), 2, S("12345"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345"), 0, 6, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("12345"), 1, 2, S("ab23cde"));
+    test(S("abcde"), 2, S("12345"), 1, 3, S("ab234cde"));
+    test(S("abcde"), 2, S("12345"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, S("12345"), 1, 5, S("ab2345cde"));
+    test(S("abcde"), 2, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 2, 1, S("ab3cde"));
+    test(S("abcde"), 2, S("12345"), 2, 2, S("ab34cde"));
+    test(S("abcde"), 2, S("12345"), 2, 3, S("ab345cde"));
+    test(S("abcde"), 2, S("12345"), 2, 4, S("ab345cde"));
+    test(S("abcde"), 2, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 4, 1, S("ab5cde"));
+    test(S("abcde"), 2, S("12345"), 4, 2, S("ab5cde"));
+    test(S("abcde"), 2, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 8, S("ab23456789cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 10, S("ab234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 1, S("ab6cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 2, S("ab67cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 4, S("ab6789cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 5, S("ab67890cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 6, S("ab67890cde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 1, S("ab0cde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 2, S("ab0cde"));
+    test(S("abcde"), 2, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+}
+
+void test7()
+{
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 1, S("ab0cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 2, S("ab0cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345"), 0, 2, S("abcd12e"));
+    test(S("abcde"), 4, S("12345"), 0, 4, S("abcd1234e"));
+    test(S("abcde"), 4, S("12345"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345"), 0, 6, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("12345"), 1, 2, S("abcd23e"));
+    test(S("abcde"), 4, S("12345"), 1, 3, S("abcd234e"));
+    test(S("abcde"), 4, S("12345"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, S("12345"), 1, 5, S("abcd2345e"));
+    test(S("abcde"), 4, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 2, 1, S("abcd3e"));
+    test(S("abcde"), 4, S("12345"), 2, 2, S("abcd34e"));
+    test(S("abcde"), 4, S("12345"), 2, 3, S("abcd345e"));
+    test(S("abcde"), 4, S("12345"), 2, 4, S("abcd345e"));
+    test(S("abcde"), 4, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 4, 1, S("abcd5e"));
+    test(S("abcde"), 4, S("12345"), 4, 2, S("abcd5e"));
+    test(S("abcde"), 4, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 9, S("abcd123456789e"));
+}
+
+void test8()
+{
+    test(S("abcde"), 4, S("1234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 8, S("abcd23456789e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 10, S("abcd234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 5, 1, S("abcd6e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 2, S("abcd67e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 4, S("abcd6789e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 5, S("abcd67890e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 6, S("abcd67890e"));
+    test(S("abcde"), 4, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 9, 1, S("abcd0e"));
+    test(S("abcde"), 4, S("1234567890"), 9, 2, S("abcd0e"));
+    test(S("abcde"), 4, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 1, S("abcd0e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 2, S("abcd0e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345"), 0, 2, S("abcde12"));
+}
+
+void test9()
+{
+    test(S("abcde"), 5, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+}
+
+void test10()
+{
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 6, S(""), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S(""), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 11, S("can't happen"));
+}
+
+void test11()
+{
+    test(S("abcde"), 6, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 5, S("12345abcdefghij"));
+}
+
+void test12()
+{
+    test(S("abcdefghij"), 0, S("12345"), 0, 6, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 2, S("23abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 3, S("234abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 5, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 1, S("3abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 2, S("34abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 3, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 4, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 1, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 2, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+}
+
+void test13()
+{
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 6, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 2, S("a23bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 3, S("a234bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 5, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 1, S("a3bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 2, S("a34bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 3, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 4, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 1, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 2, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 1, S("a2bcdefghij"));
+}
+
+void test14()
+{
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 1, S("a6bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 2, S("a67bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 6, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 0, S("abcdefghij"));
+}
+
+void test15()
+{
+    test(S("abcdefghij"), 5, S("12345"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 2, S("abcde23fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 3, S("abcde234fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 5, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 1, S("abcde3fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 2, S("abcde34fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 3, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 4, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 1, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 2, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 1, S("abcde6fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 2, S("abcde67fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 4, S("abcde6789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 5, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 6, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+}
+
+void test16()
+{
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 6, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 2, S("abcdefghi23j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 3, S("abcdefghi234j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 5, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 1, S("abcdefghi3j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 2, S("abcdefghi34j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 3, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 4, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 1, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 2, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+}
+
+void test17()
+{
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 1, S("abcdefghi6j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 2, S("abcdefghi67j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 2, S("abcdefghij23"));
+}
+
+void test18()
+{
+    test(S("abcdefghij"), 10, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+}
+
+void test19()
+{
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 10, S("can't happen"));
+}
+
+void test20()
+{
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+}
+
+void test21()
+{
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+}
+
+void test22()
+{
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+}
+
+void test23()
+{
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+}
+
+void test24()
+{
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+}
+
+void test25()
+{
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+}
+
+void test26()
+{
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+}
+
+void test27()
+{
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+}
+
+void test28()
+{
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 6, S("can't happen"));
+}
+
+void test29()
+{
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    test13();
+    test14();
+    test15();
+    test16();
+    test17();
+    test18();
+    test19();
+    test20();
+    test21();
+    test22();
+    test23();
+    test24();
+    test25();
+    test26();
+    test27();
+    test28();
+    test29();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::op+=/char.pass.cpp b/test/strings/basic.string/string.modifiers/string::op+=/char.pass.cpp
new file mode 100644
index 0000000..a3b2cbe
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::op+=/char.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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 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"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::op+=/initializer_list.pass.cpp b/test/strings/basic.string/string.modifiers/string::op+=/initializer_list.pass.cpp
new file mode 100644
index 0000000..cae4a08
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::op+=/initializer_list.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("123");
+        s += {'a', 'b', 'c'};
+        assert(s == "123abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.modifiers/string::op+=/pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::op+=/pointer.pass.cpp
new file mode 100644
index 0000000..4216fd4
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::op+=/pointer.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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 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"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::op+=/string.pass.cpp b/test/strings/basic.string/string.modifiers/string::op+=/string.pass.cpp
new file mode 100644
index 0000000..e5aea3f
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::op+=/string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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 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"));
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_initializer_list.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..8b697e0
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_initializer_list.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& replace(iterator i1, iterator i2, initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("123def456");
+        s.replace(s.begin() + 3, s.begin() + 6, {'a', 'b', 'c'});
+        assert(s == "123abc456");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_iter_iter.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..63736c8
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_iter_iter.pass.cpp
@@ -0,0 +1,952 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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&
+//   replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2);
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include <stdio.h>
+
+template <class S, class It>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::iterator first = s.begin() + pos1;
+    typename S::iterator last = s.begin() + pos1 + n1;
+    s.replace(first, last, f, l);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type xlen = last - first;
+    typename S::size_type rlen = std::distance(f, l);
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+typedef std::string S;
+
+const char* str = "12345678901234567890";
+
+void test0()
+{
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+2, S("12"));
+    test(S(""), 0, 0, str, str+4, S("1234"));
+    test(S(""), 0, 0, str, str+5, S("12345"));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+5, S("12345"));
+    test(S(""), 0, 0, str, str+9, S("123456789"));
+    test(S(""), 0, 0, str, str+10, S("1234567890"));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+10, S("1234567890"));
+    test(S(""), 0, 0, str, str+19, S("1234567890123456789"));
+    test(S(""), 0, 0, str, str+20, S("12345678901234567890"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+2, S("12abcde"));
+    test(S("abcde"), 0, 0, str, str+4, S("1234abcde"));
+    test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+    test(S("abcde"), 0, 0, str, str+9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, str, str+19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, str, str+20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+2, S("12bcde"));
+    test(S("abcde"), 0, 1, str, str+4, S("1234bcde"));
+    test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+    test(S("abcde"), 0, 1, str, str+9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, str, str+19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, str, str+20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+2, S("12cde"));
+    test(S("abcde"), 0, 2, str, str+4, S("1234cde"));
+    test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+    test(S("abcde"), 0, 2, str, str+9, S("123456789cde"));
+    test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, str, str+19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, str, str+20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+2, S("12e"));
+    test(S("abcde"), 0, 4, str, str+4, S("1234e"));
+    test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+    test(S("abcde"), 0, 4, str, str+9, S("123456789e"));
+    test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+    test(S("abcde"), 0, 4, str, str+19, S("1234567890123456789e"));
+//     test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e"));
+//     test(S("abcde"), 0, 5, str, str+0, S(""));
+//     test(S("abcde"), 0, 5, str, str+0, S(""));
+//     test(S("abcde"), 0, 5, str, str+1, S("1"));
+//     test(S("abcde"), 0, 5, str, str+2, S("12"));
+//     test(S("abcde"), 0, 5, str, str+4, S("1234"));
+//     test(S("abcde"), 0, 5, str, str+5, S("12345"));
+//     test(S("abcde"), 0, 5, str, str+0, S(""));
+//     test(S("abcde"), 0, 5, str, str+1, S("1"));
+//     test(S("abcde"), 0, 5, str, str+5, S("12345"));
+//     test(S("abcde"), 0, 5, str, str+9, S("123456789"));
+//     test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+//     test(S("abcde"), 0, 5, str, str+0, S(""));
+//     test(S("abcde"), 0, 5, str, str+1, S("1"));
+//     test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+//     test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789"));
+//     test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890"));
+//     test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+//     test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+//     test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+//     test(S("abcde"), 1, 0, str, str+2, S("a12bcde"));
+}
+/*
+void test1()
+{
+    test(S("abcde"), 1, 0, str, str+4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+    test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, str, str+9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+    test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, str, str+19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, str, str+20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+2, S("a12cde"));
+    test(S("abcde"), 1, 1, str, str+4, S("a1234cde"));
+    test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+    test(S("abcde"), 1, 1, str, str+9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, str, str+19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, str, str+20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+2, S("a12de"));
+    test(S("abcde"), 1, 2, str, str+4, S("a1234de"));
+    test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+    test(S("abcde"), 1, 2, str, str+9, S("a123456789de"));
+    test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, str, str+19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, str, str+20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+2, S("a12e"));
+    test(S("abcde"), 1, 3, str, str+4, S("a1234e"));
+    test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+    test(S("abcde"), 1, 3, str, str+9, S("a123456789e"));
+    test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, str, str+19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, str, str+20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+2, S("a12"));
+    test(S("abcde"), 1, 4, str, str+4, S("a1234"));
+    test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+    test(S("abcde"), 1, 4, str, str+9, S("a123456789"));
+    test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+    test(S("abcde"), 1, 4, str, str+19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, str, str+20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+2, S("ab12cde"));
+    test(S("abcde"), 2, 0, str, str+4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, str, str+9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, str, str+19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, str, str+20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+    test(S("abcde"), 2, 1, str, str+2, S("ab12de"));
+    test(S("abcde"), 2, 1, str, str+4, S("ab1234de"));
+    test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+}
+
+void test2()
+{
+    test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+    test(S("abcde"), 2, 1, str, str+9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+    test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, str, str+19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, str, str+20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+2, S("ab12e"));
+    test(S("abcde"), 2, 2, str, str+4, S("ab1234e"));
+    test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+    test(S("abcde"), 2, 2, str, str+9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, str, str+19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, str, str+20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+2, S("ab12"));
+    test(S("abcde"), 2, 3, str, str+4, S("ab1234"));
+    test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+    test(S("abcde"), 2, 3, str, str+9, S("ab123456789"));
+    test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, str, str+19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, str, str+20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+2, S("abcd12e"));
+    test(S("abcde"), 4, 0, str, str+4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, str, str+9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, str, str+19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, str, str+20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+2, S("abcd12"));
+    test(S("abcde"), 4, 1, str, str+4, S("abcd1234"));
+    test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+    test(S("abcde"), 4, 1, str, str+9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, str, str+19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, str, str+20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+2, S("abcde12"));
+    test(S("abcde"), 5, 0, str, str+4, S("abcde1234"));
+    test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+    test(S("abcde"), 5, 0, str, str+9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, str, str+19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, str, str+20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+}
+
+void test3()
+{
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+2, S("12j"));
+    test(S("abcdefghij"), 0, 9, str, str+4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, str, str+9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, str, str+19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, str, str+20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+2, S("12"));
+    test(S("abcdefghij"), 0, 10, str, str+4, S("1234"));
+    test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+    test(S("abcdefghij"), 0, 10, str, str+9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, str, str+19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, str, str+20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+20, S("a12345678901234567890cdefghij"));
+}
+
+void test4()
+{
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, str, str+4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, str, str+9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, str, str+19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, str, str+20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+2, S("a12"));
+    test(S("abcdefghij"), 1, 9, str, str+4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, str, str+9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, str, str+19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, str, str+20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, str, str+4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, str, str+9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, str, str+19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, str, str+20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+2, S("abcde12j"));
+}
+
+void test5()
+{
+    test(S("abcdefghij"), 5, 4, str, str+4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, str, str+9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, str, str+19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, str, str+20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, str, str+4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, str, str+9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, str, str+19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, str, str+20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, str, str+4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, str, str+9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, str, str+19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, str, str+20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, str, str+4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, str, str+9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, str, str+19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, str, str+20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, str, str+4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, str, str+9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, str, str+20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+}
+
+void test6()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+}
+
+void test7()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+20, S("abcdefghij12345678901234567890t"));
+}
+
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+*/
+int main()
+{
+    test0();
+//     test1();
+//     test2();
+//     test3();
+//     test4();
+//     test5();
+//     test6();
+//     test7();
+//     test8();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer.pass.cpp
new file mode 100644
index 0000000..19fb890
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer.pass.cpp
@@ -0,0 +1,270 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(iterator i1, iterator i2, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S::size_type n1, const S::value_type* str, S expected)
+{
+    S::size_type old_size = s.size();
+    S::iterator first = s.begin() + pos1;
+    S::iterator last = s.begin() + pos1 + n1;
+    s.replace(first, last, str);
+    assert(s.__invariants());
+    assert(s == expected);
+    S::size_type xlen = last - first;
+    S::size_type rlen = S::traits_type::length(str);
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+void test0()
+{
+    test(S(""), 0, 0, "", S(""));
+    test(S(""), 0, 0, "12345", S("12345"));
+    test(S(""), 0, 0, "1234567890", S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 0, 0, "", S("abcde"));
+    test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", S("bcde"));
+    test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", S("cde"));
+    test(S("abcde"), 0, 2, "12345", S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", S("e"));
+    test(S("abcde"), 0, 4, "12345", S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", S(""));
+    test(S("abcde"), 0, 5, "12345", S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", S("abcde"));
+    test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", S("acde"));
+    test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", S("ade"));
+    test(S("abcde"), 1, 2, "12345", S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", S("ae"));
+    test(S("abcde"), 1, 3, "12345", S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", S("a"));
+    test(S("abcde"), 1, 4, "12345", S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", S("abcde"));
+    test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", S("abde"));
+    test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", S("abe"));
+    test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", S("ab"));
+    test(S("abcde"), 2, 3, "12345", S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", S("abcde"));
+    test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", S("abcd"));
+    test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", S("abcde"));
+    test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", S(""));
+    test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+}
+
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, "", S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer_size.pass.cpp
new file mode 100644
index 0000000..e52f2ab
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_pointer_size.pass.cpp
@@ -0,0 +1,949 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(iterator i1, iterator i2, const charT* s, size_type n);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S::size_type n1, const S::value_type* str,
+     S::size_type n2, S expected)
+{
+    S::size_type old_size = s.size();
+    S::iterator first = s.begin() + pos1;
+    S::iterator last = s.begin() + pos1 + n1;
+    s.replace(first, last, str, n2);
+    assert(s.__invariants());
+    assert(s == expected);
+    S::size_type xlen = last - first;
+    S::size_type rlen = n2;
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+void test0()
+{
+    test(S(""), 0, 0, "", 0, S(""));
+    test(S(""), 0, 0, "12345", 0, S(""));
+    test(S(""), 0, 0, "12345", 1, S("1"));
+    test(S(""), 0, 0, "12345", 2, S("12"));
+    test(S(""), 0, 0, "12345", 4, S("1234"));
+    test(S(""), 0, 0, "12345", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 0, S(""));
+    test(S(""), 0, 0, "1234567890", 1, S("1"));
+    test(S(""), 0, 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+    test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+    test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+    test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+    test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+    test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+    test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345", 2, S("12"));
+    test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+}
+
+void test1()
+{
+    test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+    test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+    test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+    test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+    test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+    test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+    test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+}
+
+void test2()
+{
+    test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+    test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+}
+
+void test3()
+{
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+    test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+}
+
+void test4()
+{
+    test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+}
+
+void test5()
+{
+    test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+}
+
+void test6()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+}
+
+void test7()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+}
+
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_size_char.pass.cpp
new file mode 100644
index 0000000..51d7e14
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_size_char.pass.cpp
@@ -0,0 +1,271 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(iterator i1, iterator i2, size_type n, charT c);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S::size_type n1, S::size_type n2,
+     S::value_type c, S expected)
+{
+    S::size_type old_size = s.size();
+    S::iterator first = s.begin() + pos1;
+    S::iterator last = s.begin() + pos1 + n1;
+    s.replace(first, last, n2, c);
+    assert(s.__invariants());
+    assert(s == expected);
+    S::size_type xlen = last - first;
+    S::size_type rlen = n2;
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+void test0()
+{
+    test(S(""), 0, 0, 0, '3', S(""));
+    test(S(""), 0, 0, 5, '3', S("33333"));
+    test(S(""), 0, 0, 10, '3', S("3333333333"));
+    test(S(""), 0, 0, 20, '3', S("33333333333333333333"));
+    test(S("abcde"), 0, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 0, 0, 5, '3', S("33333abcde"));
+    test(S("abcde"), 0, 0, 10, '3', S("3333333333abcde"));
+    test(S("abcde"), 0, 0, 20, '3', S("33333333333333333333abcde"));
+    test(S("abcde"), 0, 1, 0, '3', S("bcde"));
+    test(S("abcde"), 0, 1, 5, '3', S("33333bcde"));
+    test(S("abcde"), 0, 1, 10, '3', S("3333333333bcde"));
+    test(S("abcde"), 0, 1, 20, '3', S("33333333333333333333bcde"));
+    test(S("abcde"), 0, 2, 0, '3', S("cde"));
+    test(S("abcde"), 0, 2, 5, '3', S("33333cde"));
+    test(S("abcde"), 0, 2, 10, '3', S("3333333333cde"));
+    test(S("abcde"), 0, 2, 20, '3', S("33333333333333333333cde"));
+    test(S("abcde"), 0, 4, 0, '3', S("e"));
+    test(S("abcde"), 0, 4, 5, '3', S("33333e"));
+    test(S("abcde"), 0, 4, 10, '3', S("3333333333e"));
+    test(S("abcde"), 0, 4, 20, '3', S("33333333333333333333e"));
+    test(S("abcde"), 0, 5, 0, '3', S(""));
+    test(S("abcde"), 0, 5, 5, '3', S("33333"));
+    test(S("abcde"), 0, 5, 10, '3', S("3333333333"));
+    test(S("abcde"), 0, 5, 20, '3', S("33333333333333333333"));
+    test(S("abcde"), 1, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 1, 0, 5, '3', S("a33333bcde"));
+    test(S("abcde"), 1, 0, 10, '3', S("a3333333333bcde"));
+    test(S("abcde"), 1, 0, 20, '3', S("a33333333333333333333bcde"));
+    test(S("abcde"), 1, 1, 0, '3', S("acde"));
+    test(S("abcde"), 1, 1, 5, '3', S("a33333cde"));
+    test(S("abcde"), 1, 1, 10, '3', S("a3333333333cde"));
+    test(S("abcde"), 1, 1, 20, '3', S("a33333333333333333333cde"));
+    test(S("abcde"), 1, 2, 0, '3', S("ade"));
+    test(S("abcde"), 1, 2, 5, '3', S("a33333de"));
+    test(S("abcde"), 1, 2, 10, '3', S("a3333333333de"));
+    test(S("abcde"), 1, 2, 20, '3', S("a33333333333333333333de"));
+    test(S("abcde"), 1, 3, 0, '3', S("ae"));
+    test(S("abcde"), 1, 3, 5, '3', S("a33333e"));
+    test(S("abcde"), 1, 3, 10, '3', S("a3333333333e"));
+    test(S("abcde"), 1, 3, 20, '3', S("a33333333333333333333e"));
+    test(S("abcde"), 1, 4, 0, '3', S("a"));
+    test(S("abcde"), 1, 4, 5, '3', S("a33333"));
+    test(S("abcde"), 1, 4, 10, '3', S("a3333333333"));
+    test(S("abcde"), 1, 4, 20, '3', S("a33333333333333333333"));
+    test(S("abcde"), 2, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 2, 0, 5, '3', S("ab33333cde"));
+    test(S("abcde"), 2, 0, 10, '3', S("ab3333333333cde"));
+    test(S("abcde"), 2, 0, 20, '3', S("ab33333333333333333333cde"));
+    test(S("abcde"), 2, 1, 0, '3', S("abde"));
+    test(S("abcde"), 2, 1, 5, '3', S("ab33333de"));
+    test(S("abcde"), 2, 1, 10, '3', S("ab3333333333de"));
+    test(S("abcde"), 2, 1, 20, '3', S("ab33333333333333333333de"));
+    test(S("abcde"), 2, 2, 0, '3', S("abe"));
+    test(S("abcde"), 2, 2, 5, '3', S("ab33333e"));
+    test(S("abcde"), 2, 2, 10, '3', S("ab3333333333e"));
+    test(S("abcde"), 2, 2, 20, '3', S("ab33333333333333333333e"));
+    test(S("abcde"), 2, 3, 0, '3', S("ab"));
+    test(S("abcde"), 2, 3, 5, '3', S("ab33333"));
+    test(S("abcde"), 2, 3, 10, '3', S("ab3333333333"));
+    test(S("abcde"), 2, 3, 20, '3', S("ab33333333333333333333"));
+    test(S("abcde"), 4, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 4, 0, 5, '3', S("abcd33333e"));
+    test(S("abcde"), 4, 0, 10, '3', S("abcd3333333333e"));
+    test(S("abcde"), 4, 0, 20, '3', S("abcd33333333333333333333e"));
+    test(S("abcde"), 4, 1, 0, '3', S("abcd"));
+    test(S("abcde"), 4, 1, 5, '3', S("abcd33333"));
+    test(S("abcde"), 4, 1, 10, '3', S("abcd3333333333"));
+    test(S("abcde"), 4, 1, 20, '3', S("abcd33333333333333333333"));
+    test(S("abcde"), 5, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 5, 0, 5, '3', S("abcde33333"));
+    test(S("abcde"), 5, 0, 10, '3', S("abcde3333333333"));
+    test(S("abcde"), 5, 0, 20, '3', S("abcde33333333333333333333"));
+    test(S("abcdefghij"), 0, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 5, '3', S("33333abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 10, '3', S("3333333333abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 20, '3', S("33333333333333333333abcdefghij"));
+    test(S("abcdefghij"), 0, 1, 0, '3', S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 5, '3', S("33333bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 10, '3', S("3333333333bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 20, '3', S("33333333333333333333bcdefghij"));
+    test(S("abcdefghij"), 0, 5, 0, '3', S("fghij"));
+    test(S("abcdefghij"), 0, 5, 5, '3', S("33333fghij"));
+    test(S("abcdefghij"), 0, 5, 10, '3', S("3333333333fghij"));
+    test(S("abcdefghij"), 0, 5, 20, '3', S("33333333333333333333fghij"));
+    test(S("abcdefghij"), 0, 9, 0, '3', S("j"));
+    test(S("abcdefghij"), 0, 9, 5, '3', S("33333j"));
+    test(S("abcdefghij"), 0, 9, 10, '3', S("3333333333j"));
+    test(S("abcdefghij"), 0, 9, 20, '3', S("33333333333333333333j"));
+    test(S("abcdefghij"), 0, 10, 0, '3', S(""));
+    test(S("abcdefghij"), 0, 10, 5, '3', S("33333"));
+    test(S("abcdefghij"), 0, 10, 10, '3', S("3333333333"));
+    test(S("abcdefghij"), 0, 10, 20, '3', S("33333333333333333333"));
+    test(S("abcdefghij"), 1, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, 5, '3', S("a33333bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 10, '3', S("a3333333333bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 20, '3', S("a33333333333333333333bcdefghij"));
+    test(S("abcdefghij"), 1, 1, 0, '3', S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, 5, '3', S("a33333cdefghij"));
+    test(S("abcdefghij"), 1, 1, 10, '3', S("a3333333333cdefghij"));
+    test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij"));
+}
+
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, 0, '3', S("afghij"));
+    test(S("abcdefghij"), 1, 4, 5, '3', S("a33333fghij"));
+    test(S("abcdefghij"), 1, 4, 10, '3', S("a3333333333fghij"));
+    test(S("abcdefghij"), 1, 4, 20, '3', S("a33333333333333333333fghij"));
+    test(S("abcdefghij"), 1, 8, 0, '3', S("aj"));
+    test(S("abcdefghij"), 1, 8, 5, '3', S("a33333j"));
+    test(S("abcdefghij"), 1, 8, 10, '3', S("a3333333333j"));
+    test(S("abcdefghij"), 1, 8, 20, '3', S("a33333333333333333333j"));
+    test(S("abcdefghij"), 1, 9, 0, '3', S("a"));
+    test(S("abcdefghij"), 1, 9, 5, '3', S("a33333"));
+    test(S("abcdefghij"), 1, 9, 10, '3', S("a3333333333"));
+    test(S("abcdefghij"), 1, 9, 20, '3', S("a33333333333333333333"));
+    test(S("abcdefghij"), 5, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, 5, '3', S("abcde33333fghij"));
+    test(S("abcdefghij"), 5, 0, 10, '3', S("abcde3333333333fghij"));
+    test(S("abcdefghij"), 5, 0, 20, '3', S("abcde33333333333333333333fghij"));
+    test(S("abcdefghij"), 5, 1, 0, '3', S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, 5, '3', S("abcde33333ghij"));
+    test(S("abcdefghij"), 5, 1, 10, '3', S("abcde3333333333ghij"));
+    test(S("abcdefghij"), 5, 1, 20, '3', S("abcde33333333333333333333ghij"));
+    test(S("abcdefghij"), 5, 2, 0, '3', S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, 5, '3', S("abcde33333hij"));
+    test(S("abcdefghij"), 5, 2, 10, '3', S("abcde3333333333hij"));
+    test(S("abcdefghij"), 5, 2, 20, '3', S("abcde33333333333333333333hij"));
+    test(S("abcdefghij"), 5, 4, 0, '3', S("abcdej"));
+    test(S("abcdefghij"), 5, 4, 5, '3', S("abcde33333j"));
+    test(S("abcdefghij"), 5, 4, 10, '3', S("abcde3333333333j"));
+    test(S("abcdefghij"), 5, 4, 20, '3', S("abcde33333333333333333333j"));
+    test(S("abcdefghij"), 5, 5, 0, '3', S("abcde"));
+    test(S("abcdefghij"), 5, 5, 5, '3', S("abcde33333"));
+    test(S("abcdefghij"), 5, 5, 10, '3', S("abcde3333333333"));
+    test(S("abcdefghij"), 5, 5, 20, '3', S("abcde33333333333333333333"));
+    test(S("abcdefghij"), 9, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, 5, '3', S("abcdefghi33333j"));
+    test(S("abcdefghij"), 9, 0, 10, '3', S("abcdefghi3333333333j"));
+    test(S("abcdefghij"), 9, 0, 20, '3', S("abcdefghi33333333333333333333j"));
+    test(S("abcdefghij"), 9, 1, 0, '3', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, 5, '3', S("abcdefghi33333"));
+    test(S("abcdefghij"), 9, 1, 10, '3', S("abcdefghi3333333333"));
+    test(S("abcdefghij"), 9, 1, 20, '3', S("abcdefghi33333333333333333333"));
+    test(S("abcdefghij"), 10, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, 5, '3', S("abcdefghij33333"));
+    test(S("abcdefghij"), 10, 0, 10, '3', S("abcdefghij3333333333"));
+    test(S("abcdefghij"), 10, 0, 20, '3', S("abcdefghij33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 5, '3', S("33333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 10, '3', S("3333333333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 20, '3', S("33333333333333333333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 0, '3', S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 5, '3', S("33333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 10, '3', S("3333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 20, '3', S("33333333333333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 0, '3', S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 5, '3', S("33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 10, '3', S("3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 20, '3', S("33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 0, '3', S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 5, '3', S("33333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 10, '3', S("3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 20, '3', S("33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 0, '3', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 5, '3', S("33333"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 10, '3', S("3333333333"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 20, '3', S("33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 5, '3', S("a33333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 10, '3', S("a3333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 20, '3', S("a33333333333333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 0, '3', S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 5, '3', S("a33333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 10, '3', S("a3333333333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 20, '3', S("a33333333333333333333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 0, '3', S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 5, '3', S("a33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 10, '3', S("a3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 20, '3', S("a33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 0, '3', S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 5, '3', S("a33333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 10, '3', S("a3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 20, '3', S("a33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 0, '3', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 5, '3', S("a33333"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 10, '3', S("a3333333333"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 20, '3', S("a33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 5, '3', S("abcdefghij33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 10, '3', S("abcdefghij3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 20, '3', S("abcdefghij33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 0, '3', S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 5, '3', S("abcdefghij33333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 10, '3', S("abcdefghij3333333333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 20, '3', S("abcdefghij33333333333333333333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 0, '3', S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 5, '3', S("abcdefghij33333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 10, '3', S("abcdefghij3333333333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 20, '3', S("abcdefghij33333333333333333333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 0, '3', S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 5, '3', S("abcdefghij33333t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 10, '3', S("abcdefghij3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 5, '3', S("abcdefghij33333"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 10, '3', S("abcdefghij3333333333"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 20, '3', S("abcdefghij33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 5, '3', S("abcdefghijklmnopqrs33333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 10, '3', S("abcdefghijklmnopqrs3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 20, '3', S("abcdefghijklmnopqrs33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 0, '3', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 5, '3', S("abcdefghijklmnopqrs33333"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 10, '3', S("abcdefghijklmnopqrs3333333333"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 20, '3', S("abcdefghijklmnopqrs33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 5, '3', S("abcdefghijklmnopqrst33333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 10, '3', S("abcdefghijklmnopqrst3333333333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 20, '3', S("abcdefghijklmnopqrst33333333333333333333"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/iter_iter_string.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_string.pass.cpp
new file mode 100644
index 0000000..9cfaafb
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/iter_iter_string.pass.cpp
@@ -0,0 +1,270 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(iterator i1, iterator i2, const basic_string& str);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
+{
+    S::size_type old_size = s.size();
+    S::iterator first = s.begin() + pos1;
+    S::iterator last = s.begin() + pos1 + n1;
+    s.replace(first, last, str);
+    assert(s.__invariants());
+    assert(s == expected);
+    S::size_type xlen = last - first;
+    S::size_type rlen = str.size();
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+void test0()
+{
+    test(S(""), 0, 0, S(""), S(""));
+    test(S(""), 0, 0, S("12345"), S("12345"));
+    test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 0, 0, S(""), S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, S(""), S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, S(""), S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, S(""), S("e"));
+    test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, S(""), S(""));
+    test(S("abcde"), 0, 5, S("12345"), S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 1, 0, S(""), S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, S(""), S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, S(""), S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, S(""), S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, S(""), S("a"));
+    test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, S(""), S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, S(""), S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, S(""), S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, S(""), S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, S(""), S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, S(""), S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, S(""), S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, S(""), S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, S(""), S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+}
+
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, S(""), S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer.pass.cpp
new file mode 100644
index 0000000..299dc57
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer.pass.cpp
@@ -0,0 +1,360 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(size_type pos, size_type n1, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s,   S::size_type pos, S::size_type n1,
+     const S::value_type* str, S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        S::size_type xlen = std::min(n1, old_size - pos);
+        S::size_type rlen = S::traits_type::length(str);
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, 0, "", S(""));
+    test(S(""), 0, 0, "12345", S("12345"));
+    test(S(""), 0, 0, "1234567890", S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 0, 1, "", S(""));
+    test(S(""), 0, 1, "12345", S("12345"));
+    test(S(""), 0, 1, "1234567890", S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 1, 0, "", S("can't happen"));
+    test(S(""), 1, 0, "12345", S("can't happen"));
+    test(S(""), 1, 0, "1234567890", S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", S("can't happen"));
+    test(S("abcde"), 0, 0, "", S("abcde"));
+    test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", S("bcde"));
+    test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", S("cde"));
+    test(S("abcde"), 0, 2, "12345", S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", S("e"));
+    test(S("abcde"), 0, 4, "12345", S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", S(""));
+    test(S("abcde"), 0, 5, "12345", S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 0, 6, "", S(""));
+    test(S("abcde"), 0, 6, "12345", S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", S("abcde"));
+    test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", S("acde"));
+    test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", S("ade"));
+    test(S("abcde"), 1, 2, "12345", S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", S("ae"));
+    test(S("abcde"), 1, 3, "12345", S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", S("a"));
+    test(S("abcde"), 1, 4, "12345", S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, "", S("a"));
+    test(S("abcde"), 1, 5, "12345", S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", S("abcde"));
+    test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", S("abde"));
+    test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", S("abe"));
+    test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", S("ab"));
+    test(S("abcde"), 2, 3, "12345", S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, "", S("ab"));
+    test(S("abcde"), 2, 4, "12345", S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", S("abcde"));
+    test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", S("abcd"));
+    test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, "", S("abcd"));
+    test(S("abcde"), 4, 2, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", S("abcde"));
+    test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, "", S("abcde"));
+    test(S("abcde"), 5, 1, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", S("abcde12345678901234567890"));
+}
+
+void test1()
+{
+    test(S("abcde"), 6, 0, "", S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", S(""));
+    test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, "", S(""));
+    test(S("abcdefghij"), 0, 11, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, "", S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, "", S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, "", S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, "", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", S("can't happen"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer_size.pass.cpp
new file mode 100644
index 0000000..4719fe4
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1294 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(size_type pos, size_type n1, const charT* s, size_type n2);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s,   S::size_type pos, S::size_type n1,
+     const S::value_type* str, S::size_type n2,
+     S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, str, n2);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        S::size_type xlen = std::min(n1, old_size - pos);
+        S::size_type rlen = n2;
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, 0, "", 0, S(""));
+    test(S(""), 0, 0, "12345", 0, S(""));
+    test(S(""), 0, 0, "12345", 1, S("1"));
+    test(S(""), 0, 0, "12345", 2, S("12"));
+    test(S(""), 0, 0, "12345", 4, S("1234"));
+    test(S(""), 0, 0, "12345", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 0, S(""));
+    test(S(""), 0, 0, "1234567890", 1, S("1"));
+    test(S(""), 0, 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 0, 1, "", 0, S(""));
+    test(S(""), 0, 1, "12345", 0, S(""));
+    test(S(""), 0, 1, "12345", 1, S("1"));
+    test(S(""), 0, 1, "12345", 2, S("12"));
+    test(S(""), 0, 1, "12345", 4, S("1234"));
+    test(S(""), 0, 1, "12345", 5, S("12345"));
+    test(S(""), 0, 1, "1234567890", 0, S(""));
+    test(S(""), 0, 1, "1234567890", 1, S("1"));
+    test(S(""), 0, 1, "1234567890", 5, S("12345"));
+    test(S(""), 0, 1, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 1, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 1, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 1, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 1, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 1, 0, "", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345", 1, S("can't happen"));
+    test(S(""), 1, 0, "12345", 2, S("can't happen"));
+    test(S(""), 1, 0, "12345", 4, S("can't happen"));
+    test(S(""), 1, 0, "12345", 5, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 0, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 1, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 5, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 9, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 10, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcde"), 0, 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+    test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+    test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+    test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+}
+
+void test1()
+{
+    test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+    test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+    test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345", 2, S("12"));
+    test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, "", 0, S(""));
+    test(S("abcde"), 0, 6, "12345", 0, S(""));
+    test(S("abcde"), 0, 6, "12345", 1, S("1"));
+    test(S("abcde"), 0, 6, "12345", 2, S("12"));
+    test(S("abcde"), 0, 6, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 6, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 6, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 6, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 6, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 6, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+    test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+    test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+    test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+    test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+    test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+    test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+}
+
+void test2()
+{
+    test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, "", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 5, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 5, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 5, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 5, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 5, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 5, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+    test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+    test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+}
+
+void test3()
+{
+    test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, "", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 4, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 4, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 4, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, "", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 2, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 2, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, "", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 1, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 1, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890"));
+}
+
+void test4()
+{
+    test(S("abcde"), 6, 0, "", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 2, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 4, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 5, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+    test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, "", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "12345", 2, S("12"));
+}
+
+void test5()
+{
+    test(S("abcdefghij"), 0, 11, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 11, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 10, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 10, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1"));
+}
+
+void test6()
+{
+    test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+    test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 6, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 6, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde"));
+}
+
+void test7()
+{
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 2, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 2, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 1, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 1, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, "", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+}
+
+void test9()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+}
+
+void test10()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+}
+
+void test11()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/size_size_size_char.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/size_size_size_char.pass.cpp
new file mode 100644
index 0000000..738c62d
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/size_size_size_char.pass.cpp
@@ -0,0 +1,359 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(size_type pos, size_type n1, size_type n2, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s,   S::size_type pos, S::size_type n1,
+     S::size_type n2, S::value_type c,
+     S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, n2, c);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        S::size_type xlen = std::min(n1, old_size - pos);
+        S::size_type rlen = n2;
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, 0, 0, '2', S(""));
+    test(S(""), 0, 0, 5, '2', S("22222"));
+    test(S(""), 0, 0, 10, '2', S("2222222222"));
+    test(S(""), 0, 0, 20, '2', S("22222222222222222222"));
+    test(S(""), 0, 1, 0, '2', S(""));
+    test(S(""), 0, 1, 5, '2', S("22222"));
+    test(S(""), 0, 1, 10, '2', S("2222222222"));
+    test(S(""), 0, 1, 20, '2', S("22222222222222222222"));
+    test(S(""), 1, 0, 0, '2', S("can't happen"));
+    test(S(""), 1, 0, 5, '2', S("can't happen"));
+    test(S(""), 1, 0, 10, '2', S("can't happen"));
+    test(S(""), 1, 0, 20, '2', S("can't happen"));
+    test(S("abcde"), 0, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 0, 0, 5, '2', S("22222abcde"));
+    test(S("abcde"), 0, 0, 10, '2', S("2222222222abcde"));
+    test(S("abcde"), 0, 0, 20, '2', S("22222222222222222222abcde"));
+    test(S("abcde"), 0, 1, 0, '2', S("bcde"));
+    test(S("abcde"), 0, 1, 5, '2', S("22222bcde"));
+    test(S("abcde"), 0, 1, 10, '2', S("2222222222bcde"));
+    test(S("abcde"), 0, 1, 20, '2', S("22222222222222222222bcde"));
+    test(S("abcde"), 0, 2, 0, '2', S("cde"));
+    test(S("abcde"), 0, 2, 5, '2', S("22222cde"));
+    test(S("abcde"), 0, 2, 10, '2', S("2222222222cde"));
+    test(S("abcde"), 0, 2, 20, '2', S("22222222222222222222cde"));
+    test(S("abcde"), 0, 4, 0, '2', S("e"));
+    test(S("abcde"), 0, 4, 5, '2', S("22222e"));
+    test(S("abcde"), 0, 4, 10, '2', S("2222222222e"));
+    test(S("abcde"), 0, 4, 20, '2', S("22222222222222222222e"));
+    test(S("abcde"), 0, 5, 0, '2', S(""));
+    test(S("abcde"), 0, 5, 5, '2', S("22222"));
+    test(S("abcde"), 0, 5, 10, '2', S("2222222222"));
+    test(S("abcde"), 0, 5, 20, '2', S("22222222222222222222"));
+    test(S("abcde"), 0, 6, 0, '2', S(""));
+    test(S("abcde"), 0, 6, 5, '2', S("22222"));
+    test(S("abcde"), 0, 6, 10, '2', S("2222222222"));
+    test(S("abcde"), 0, 6, 20, '2', S("22222222222222222222"));
+    test(S("abcde"), 1, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 1, 0, 5, '2', S("a22222bcde"));
+    test(S("abcde"), 1, 0, 10, '2', S("a2222222222bcde"));
+    test(S("abcde"), 1, 0, 20, '2', S("a22222222222222222222bcde"));
+    test(S("abcde"), 1, 1, 0, '2', S("acde"));
+    test(S("abcde"), 1, 1, 5, '2', S("a22222cde"));
+    test(S("abcde"), 1, 1, 10, '2', S("a2222222222cde"));
+    test(S("abcde"), 1, 1, 20, '2', S("a22222222222222222222cde"));
+    test(S("abcde"), 1, 2, 0, '2', S("ade"));
+    test(S("abcde"), 1, 2, 5, '2', S("a22222de"));
+    test(S("abcde"), 1, 2, 10, '2', S("a2222222222de"));
+    test(S("abcde"), 1, 2, 20, '2', S("a22222222222222222222de"));
+    test(S("abcde"), 1, 3, 0, '2', S("ae"));
+    test(S("abcde"), 1, 3, 5, '2', S("a22222e"));
+    test(S("abcde"), 1, 3, 10, '2', S("a2222222222e"));
+    test(S("abcde"), 1, 3, 20, '2', S("a22222222222222222222e"));
+    test(S("abcde"), 1, 4, 0, '2', S("a"));
+    test(S("abcde"), 1, 4, 5, '2', S("a22222"));
+    test(S("abcde"), 1, 4, 10, '2', S("a2222222222"));
+    test(S("abcde"), 1, 4, 20, '2', S("a22222222222222222222"));
+    test(S("abcde"), 1, 5, 0, '2', S("a"));
+    test(S("abcde"), 1, 5, 5, '2', S("a22222"));
+    test(S("abcde"), 1, 5, 10, '2', S("a2222222222"));
+    test(S("abcde"), 1, 5, 20, '2', S("a22222222222222222222"));
+    test(S("abcde"), 2, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 2, 0, 5, '2', S("ab22222cde"));
+    test(S("abcde"), 2, 0, 10, '2', S("ab2222222222cde"));
+    test(S("abcde"), 2, 0, 20, '2', S("ab22222222222222222222cde"));
+    test(S("abcde"), 2, 1, 0, '2', S("abde"));
+    test(S("abcde"), 2, 1, 5, '2', S("ab22222de"));
+    test(S("abcde"), 2, 1, 10, '2', S("ab2222222222de"));
+    test(S("abcde"), 2, 1, 20, '2', S("ab22222222222222222222de"));
+    test(S("abcde"), 2, 2, 0, '2', S("abe"));
+    test(S("abcde"), 2, 2, 5, '2', S("ab22222e"));
+    test(S("abcde"), 2, 2, 10, '2', S("ab2222222222e"));
+    test(S("abcde"), 2, 2, 20, '2', S("ab22222222222222222222e"));
+    test(S("abcde"), 2, 3, 0, '2', S("ab"));
+    test(S("abcde"), 2, 3, 5, '2', S("ab22222"));
+    test(S("abcde"), 2, 3, 10, '2', S("ab2222222222"));
+    test(S("abcde"), 2, 3, 20, '2', S("ab22222222222222222222"));
+    test(S("abcde"), 2, 4, 0, '2', S("ab"));
+    test(S("abcde"), 2, 4, 5, '2', S("ab22222"));
+    test(S("abcde"), 2, 4, 10, '2', S("ab2222222222"));
+    test(S("abcde"), 2, 4, 20, '2', S("ab22222222222222222222"));
+    test(S("abcde"), 4, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 4, 0, 5, '2', S("abcd22222e"));
+    test(S("abcde"), 4, 0, 10, '2', S("abcd2222222222e"));
+    test(S("abcde"), 4, 0, 20, '2', S("abcd22222222222222222222e"));
+    test(S("abcde"), 4, 1, 0, '2', S("abcd"));
+    test(S("abcde"), 4, 1, 5, '2', S("abcd22222"));
+    test(S("abcde"), 4, 1, 10, '2', S("abcd2222222222"));
+    test(S("abcde"), 4, 1, 20, '2', S("abcd22222222222222222222"));
+    test(S("abcde"), 4, 2, 0, '2', S("abcd"));
+    test(S("abcde"), 4, 2, 5, '2', S("abcd22222"));
+    test(S("abcde"), 4, 2, 10, '2', S("abcd2222222222"));
+    test(S("abcde"), 4, 2, 20, '2', S("abcd22222222222222222222"));
+    test(S("abcde"), 5, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 5, 0, 5, '2', S("abcde22222"));
+    test(S("abcde"), 5, 0, 10, '2', S("abcde2222222222"));
+    test(S("abcde"), 5, 0, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcde"), 5, 1, 0, '2', S("abcde"));
+    test(S("abcde"), 5, 1, 5, '2', S("abcde22222"));
+    test(S("abcde"), 5, 1, 10, '2', S("abcde2222222222"));
+    test(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"));
+}
+
+void test1()
+{
+    test(S("abcde"), 6, 0, 0, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 5, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 10, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 20, '2', S("can't happen"));
+    test(S("abcdefghij"), 0, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 5, '2', S("22222abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 10, '2', S("2222222222abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 20, '2', S("22222222222222222222abcdefghij"));
+    test(S("abcdefghij"), 0, 1, 0, '2', S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 5, '2', S("22222bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 10, '2', S("2222222222bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 20, '2', S("22222222222222222222bcdefghij"));
+    test(S("abcdefghij"), 0, 5, 0, '2', S("fghij"));
+    test(S("abcdefghij"), 0, 5, 5, '2', S("22222fghij"));
+    test(S("abcdefghij"), 0, 5, 10, '2', S("2222222222fghij"));
+    test(S("abcdefghij"), 0, 5, 20, '2', S("22222222222222222222fghij"));
+    test(S("abcdefghij"), 0, 9, 0, '2', S("j"));
+    test(S("abcdefghij"), 0, 9, 5, '2', S("22222j"));
+    test(S("abcdefghij"), 0, 9, 10, '2', S("2222222222j"));
+    test(S("abcdefghij"), 0, 9, 20, '2', S("22222222222222222222j"));
+    test(S("abcdefghij"), 0, 10, 0, '2', S(""));
+    test(S("abcdefghij"), 0, 10, 5, '2', S("22222"));
+    test(S("abcdefghij"), 0, 10, 10, '2', S("2222222222"));
+    test(S("abcdefghij"), 0, 10, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghij"), 0, 11, 0, '2', S(""));
+    test(S("abcdefghij"), 0, 11, 5, '2', S("22222"));
+    test(S("abcdefghij"), 0, 11, 10, '2', S("2222222222"));
+    test(S("abcdefghij"), 0, 11, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghij"), 1, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, 5, '2', S("a22222bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 10, '2', S("a2222222222bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 20, '2', S("a22222222222222222222bcdefghij"));
+    test(S("abcdefghij"), 1, 1, 0, '2', S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, 5, '2', S("a22222cdefghij"));
+    test(S("abcdefghij"), 1, 1, 10, '2', S("a2222222222cdefghij"));
+    test(S("abcdefghij"), 1, 1, 20, '2', S("a22222222222222222222cdefghij"));
+    test(S("abcdefghij"), 1, 4, 0, '2', S("afghij"));
+    test(S("abcdefghij"), 1, 4, 5, '2', S("a22222fghij"));
+    test(S("abcdefghij"), 1, 4, 10, '2', S("a2222222222fghij"));
+    test(S("abcdefghij"), 1, 4, 20, '2', S("a22222222222222222222fghij"));
+    test(S("abcdefghij"), 1, 8, 0, '2', S("aj"));
+    test(S("abcdefghij"), 1, 8, 5, '2', S("a22222j"));
+    test(S("abcdefghij"), 1, 8, 10, '2', S("a2222222222j"));
+    test(S("abcdefghij"), 1, 8, 20, '2', S("a22222222222222222222j"));
+    test(S("abcdefghij"), 1, 9, 0, '2', S("a"));
+    test(S("abcdefghij"), 1, 9, 5, '2', S("a22222"));
+    test(S("abcdefghij"), 1, 9, 10, '2', S("a2222222222"));
+    test(S("abcdefghij"), 1, 9, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghij"), 1, 10, 0, '2', S("a"));
+    test(S("abcdefghij"), 1, 10, 5, '2', S("a22222"));
+    test(S("abcdefghij"), 1, 10, 10, '2', S("a2222222222"));
+    test(S("abcdefghij"), 1, 10, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghij"), 5, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, 5, '2', S("abcde22222fghij"));
+    test(S("abcdefghij"), 5, 0, 10, '2', S("abcde2222222222fghij"));
+    test(S("abcdefghij"), 5, 0, 20, '2', S("abcde22222222222222222222fghij"));
+    test(S("abcdefghij"), 5, 1, 0, '2', S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, 5, '2', S("abcde22222ghij"));
+    test(S("abcdefghij"), 5, 1, 10, '2', S("abcde2222222222ghij"));
+    test(S("abcdefghij"), 5, 1, 20, '2', S("abcde22222222222222222222ghij"));
+    test(S("abcdefghij"), 5, 2, 0, '2', S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, 5, '2', S("abcde22222hij"));
+    test(S("abcdefghij"), 5, 2, 10, '2', S("abcde2222222222hij"));
+    test(S("abcdefghij"), 5, 2, 20, '2', S("abcde22222222222222222222hij"));
+    test(S("abcdefghij"), 5, 4, 0, '2', S("abcdej"));
+    test(S("abcdefghij"), 5, 4, 5, '2', S("abcde22222j"));
+    test(S("abcdefghij"), 5, 4, 10, '2', S("abcde2222222222j"));
+    test(S("abcdefghij"), 5, 4, 20, '2', S("abcde22222222222222222222j"));
+    test(S("abcdefghij"), 5, 5, 0, '2', S("abcde"));
+    test(S("abcdefghij"), 5, 5, 5, '2', S("abcde22222"));
+    test(S("abcdefghij"), 5, 5, 10, '2', S("abcde2222222222"));
+    test(S("abcdefghij"), 5, 5, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcdefghij"), 5, 6, 0, '2', S("abcde"));
+    test(S("abcdefghij"), 5, 6, 5, '2', S("abcde22222"));
+    test(S("abcdefghij"), 5, 6, 10, '2', S("abcde2222222222"));
+    test(S("abcdefghij"), 5, 6, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcdefghij"), 9, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, 5, '2', S("abcdefghi22222j"));
+    test(S("abcdefghij"), 9, 0, 10, '2', S("abcdefghi2222222222j"));
+    test(S("abcdefghij"), 9, 0, 20, '2', S("abcdefghi22222222222222222222j"));
+    test(S("abcdefghij"), 9, 1, 0, '2', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, 5, '2', S("abcdefghi22222"));
+    test(S("abcdefghij"), 9, 1, 10, '2', S("abcdefghi2222222222"));
+    test(S("abcdefghij"), 9, 1, 20, '2', S("abcdefghi22222222222222222222"));
+    test(S("abcdefghij"), 9, 2, 0, '2', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, 5, '2', S("abcdefghi22222"));
+    test(S("abcdefghij"), 9, 2, 10, '2', S("abcdefghi2222222222"));
+    test(S("abcdefghij"), 9, 2, 20, '2', S("abcdefghi22222222222222222222"));
+    test(S("abcdefghij"), 10, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghij"), 10, 0, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghij"), 10, 0, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghij"), 10, 1, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghij"), 10, 1, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghij"), 10, 1, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghij"), 11, 0, 0, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 5, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 10, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 20, '2', S("can't happen"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 5, '2', S("22222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 10, '2', S("2222222222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 20, '2', S("22222222222222222222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 0, '2', S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 5, '2', S("22222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 10, '2', S("2222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 20, '2', S("22222222222222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 0, '2', S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 5, '2', S("22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 10, '2', S("2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 20, '2', S("22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 0, '2', S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 5, '2', S("22222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 10, '2', S("2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 20, '2', S("22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 0, '2', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 5, '2', S("22222"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 10, '2', S("2222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 0, '2', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 5, '2', S("22222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 10, '2', S("2222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 5, '2', S("a22222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 10, '2', S("a2222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 20, '2', S("a22222222222222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 0, '2', S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 5, '2', S("a22222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 10, '2', S("a2222222222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 20, '2', S("a22222222222222222222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 0, '2', S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 5, '2', S("a22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 10, '2', S("a2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 20, '2', S("a22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 0, '2', S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 5, '2', S("a22222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 10, '2', S("a2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 20, '2', S("a22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 0, '2', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 5, '2', S("a22222"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 10, '2', S("a2222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 0, '2', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 5, '2', S("a22222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 10, '2', S("a2222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 5, '2', S("abcdefghij22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 10, '2', S("abcdefghij2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 20, '2', S("abcdefghij22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 0, '2', S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 5, '2', S("abcdefghij22222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 10, '2', S("abcdefghij2222222222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 20, '2', S("abcdefghij22222222222222222222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 0, '2', S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 5, '2', S("abcdefghij22222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 10, '2', S("abcdefghij2222222222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 20, '2', S("abcdefghij22222222222222222222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 0, '2', S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 5, '2', S("abcdefghij22222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 10, '2', S("abcdefghij2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 20, '2', S("abcdefghij22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 0, '2', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 0, '2', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 5, '2', S("abcdefghijklmnopqrs22222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 10, '2', S("abcdefghijklmnopqrs2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 20, '2', S("abcdefghijklmnopqrs22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 0, '2', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 5, '2', S("abcdefghijklmnopqrs22222"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 0, '2', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 5, '2', S("abcdefghijklmnopqrs22222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 5, '2', S("abcdefghijklmnopqrst22222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 5, '2', S("abcdefghijklmnopqrst22222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 0, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 5, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 10, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 20, '2', S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/size_size_string.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/size_size_string.pass.cpp
new file mode 100644
index 0000000..49c4955
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/size_size_string.pass.cpp
@@ -0,0 +1,359 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos1, n1, str);
+        assert(s.__invariants());
+        assert(pos1 <= old_size);
+        assert(s == expected);
+        S::size_type xlen = std::min(n1, old_size - pos1);
+        S::size_type rlen = str.size();
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size);
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, 0, S(""), S(""));
+    test(S(""), 0, 0, S("12345"), S("12345"));
+    test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 0, 1, S(""), S(""));
+    test(S(""), 0, 1, S("12345"), S("12345"));
+    test(S(""), 0, 1, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 1, 0, S(""), S("can't happen"));
+    test(S(""), 1, 0, S("12345"), S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), S("can't happen"));
+    test(S("abcde"), 0, 0, S(""), S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, S(""), S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, S(""), S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, S(""), S("e"));
+    test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, S(""), S(""));
+    test(S("abcde"), 0, 5, S("12345"), S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S(""), S(""));
+    test(S("abcde"), 0, 6, S("12345"), S("12345"));
+    test(S("abcde"), 0, 6, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 1, 0, S(""), S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, S(""), S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, S(""), S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, S(""), S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, S(""), S("a"));
+    test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S(""), S("a"));
+    test(S("abcde"), 1, 5, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 5, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, S(""), S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, S(""), S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, S(""), S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, S(""), S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S(""), S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 4, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, S(""), S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, S(""), S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S(""), S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 2, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, S(""), S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S(""), S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 1, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890"));
+}
+
+void test1()
+{
+    test(S("abcde"), 6, 0, S(""), S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, S(""), S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, S(""), S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S(""), S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, S(""), S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S(""), S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, S(""), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::replace/size_size_string_size_size.pass.cpp b/test/strings/basic.string/string.modifiers/string::replace/size_size_string_size_size.pass.cpp
new file mode 100644
index 0000000..25cf951
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::replace/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5802 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ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>& 
+//   replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str, 
+//           size_type pos2, size_type n2);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+typedef std::string S;
+
+void
+test(S s,   S::size_type pos1, S::size_type n1,
+     S str, S::size_type pos2, S::size_type n2,
+     S expected)
+{
+    S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos1, n1, str, pos2, n2);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+        S::size_type xlen = std::min(n1, old_size - pos1);
+        S::size_type rlen = std::min(n2, str.size() - pos2);
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0, 0, S(""));
+    test(S(""), 0, 0, S(""), 0, 1, S(""));
+    test(S(""), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, 0, S("12345"), 0, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, 0, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, 0, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, 0, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, 0, S("12345"), 1, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, 0, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, 0, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, 0, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, 0, S("12345"), 2, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, 0, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, 0, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, 0, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, 0, S("12345"), 4, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, 0, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, 0, S("12345"), 5, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 5, 1, S(""));
+    test(S(""), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 0, 0, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, 0, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, 0, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 0, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, 0, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, 0, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, 0, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 0, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, 0, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, 0, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, 0, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, 0, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, 0, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, 0, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, 0, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, 0, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, 0, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 0, 1, S(""), 0, 0, S(""));
+    test(S(""), 0, 1, S(""), 0, 1, S(""));
+    test(S(""), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, 1, S("12345"), 0, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, 1, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, 1, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, 1, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, 1, S("12345"), 1, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, 1, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, 1, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, 1, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, 1, S("12345"), 2, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, 1, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, 1, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, 1, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, 1, S("12345"), 4, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, 1, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, 1, S("12345"), 5, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 5, 1, S(""));
+    test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+void test1()
+{
+    test(S(""), 0, 1, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, 1, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, 1, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 1, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, 1, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, 1, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, 1, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 1, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, 1, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, 1, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, 1, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, 1, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, 1, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, 1, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, 1, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, 1, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, 1, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 1, 0, S(""), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S(""), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+}
+
+void test2()
+{
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 2, S("12abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 6, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 2, S("23abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 3, S("234abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 5, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 1, S("3abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 2, S("34abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 3, S("345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 4, S("345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 1, S("5abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 2, S("5abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 8, S("23456789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 10, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 1, S("6abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 2, S("67abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 4, S("6789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 5, S("67890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 6, S("67890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 1, S("0abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 2, S("0abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S(""), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S(""), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde"));
+}
+
+void test3()
+{
+    test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 2, S("12bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 6, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 2, S("23bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 3, S("234bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 4, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 5, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 1, S("3bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 2, S("34bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 3, S("345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 4, S("345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 1, S("5bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 2, S("5bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 5, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 5, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 4, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 8, S("23456789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 9, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 10, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 1, S("6bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 2, S("67bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 4, S("6789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 5, S("67890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 6, S("67890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 1, S("0bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 2, S("0bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 10, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 10, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S(""), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S(""), 0, 1, S("cde"));
+    test(S("abcde"), 0, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 2, S("12cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 4, S("1234cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 6, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 2, S("23cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 3, S("234cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 4, S("2345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 5, S("2345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 1, S("3cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 2, S("34cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 3, S("345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 4, S("345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 1, S("5cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 2, S("5cde"));
+    test(S("abcde"), 0, 2, S("12345"), 5, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 5, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde"));
+}
+
+void test4()
+{
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 11, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 4, S("2345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 8, S("23456789cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 9, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 10, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 1, S("6cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 2, S("67cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 4, S("6789cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 5, S("67890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 6, S("67890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 1, S("0cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 2, S("0cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 10, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 10, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 21, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 9, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 18, S("234567890123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 19, S("2345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 20, S("2345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 11, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 1, S("0cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 2, S("0cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S(""), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S(""), 0, 1, S("e"));
+    test(S("abcde"), 0, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 2, S("12e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 4, S("1234e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 6, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 2, S("23e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 3, S("234e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 4, S("2345e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 5, S("2345e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 1, S("3e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 2, S("34e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 3, S("345e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 4, S("345e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 1, S("5e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 2, S("5e"));
+    test(S("abcde"), 0, 4, S("12345"), 5, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 5, 1, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 9, S("123456789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 11, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 4, S("2345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 8, S("23456789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 9, S("234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 10, S("234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 1, S("6e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 2, S("67e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 4, S("6789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 5, S("67890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 6, S("67890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 1, S("0e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 2, S("0e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 10, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 10, 1, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e"));
+}
+
+void test5()
+{
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 9, S("234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 18, S("234567890123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 19, S("2345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 20, S("2345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 9, S("123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 11, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 1, S("0e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 2, S("0e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 1, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S(""), 0, 1, S(""));
+    test(S("abcde"), 0, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 2, S("12"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 4, S("1234"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 6, S("12345"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 2, S("23"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 3, S("234"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 5, S("2345"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 2, 1, S("3"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 2, S("34"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 3, S("345"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 4, S("345"));
+    test(S("abcde"), 0, 5, S("12345"), 4, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 4, 1, S("5"));
+    test(S("abcde"), 0, 5, S("12345"), 4, 2, S("5"));
+    test(S("abcde"), 0, 5, S("12345"), 5, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 5, 1, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 1, S("6"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 2, S("67"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 1, S("0"));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 2, S("0"));
+    test(S("abcde"), 0, 5, S("1234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 10, 1, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S(""), 0, 1, S(""));
+    test(S("abcde"), 0, 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 2, S("12"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 4, S("1234"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345"));
+}
+
+void test6()
+{
+    test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 2, S("23"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 3, S("234"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 5, S("2345"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 2, 1, S("3"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 2, S("34"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 3, S("345"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 4, S("345"));
+    test(S("abcde"), 0, 6, S("12345"), 4, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 4, 1, S("5"));
+    test(S("abcde"), 0, 6, S("12345"), 4, 2, S("5"));
+    test(S("abcde"), 0, 6, S("12345"), 5, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 5, 1, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 1, S("6"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 2, S("67"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 1, S("0"));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 2, S("0"));
+    test(S("abcde"), 0, 6, S("1234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 10, 1, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 2, S("a12bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 6, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 2, S("a23bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 3, S("a234bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 5, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 1, S("a3bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 2, S("a34bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 3, S("a345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 4, S("a345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 1, S("a5bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 2, S("a5bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde"));
+}
+
+void test7()
+{
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 1, S("a6bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 2, S("a67bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 4, S("a6789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 5, S("a67890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 6, S("a67890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 1, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 2, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S(""), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S(""), 0, 1, S("acde"));
+    test(S("abcde"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 2, S("a12cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 6, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 2, S("a23cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 3, S("a234cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 4, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 5, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 1, S("a3cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 2, S("a34cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 3, S("a345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 4, S("a345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 1, S("a5cde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 2, S("a5cde"));
+    test(S("abcde"), 1, 1, S("12345"), 5, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 5, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 4, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 8, S("a23456789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 9, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 10, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 1, S("a6cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 2, S("a67cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 4, S("a6789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 5, S("a67890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 6, S("a67890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 1, S("a0cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 2, S("a0cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 10, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 10, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde"));
+}
+
+void test8()
+{
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S(""), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S(""), 0, 1, S("ade"));
+    test(S("abcde"), 1, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 2, S("a12de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 4, S("a1234de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 6, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 2, S("a23de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 3, S("a234de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 4, S("a2345de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 5, S("a2345de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 1, S("a3de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 2, S("a34de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 3, S("a345de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 4, S("a345de"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 1, S("a5de"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 2, S("a5de"));
+    test(S("abcde"), 1, 2, S("12345"), 5, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 5, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 11, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 4, S("a2345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 8, S("a23456789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 9, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 10, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 1, S("a6de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 2, S("a67de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 4, S("a6789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 5, S("a67890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 6, S("a67890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 1, S("a0de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 2, S("a0de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 10, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 10, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 21, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 9, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 18, S("a234567890123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 19, S("a2345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 20, S("a2345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 11, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 1, S("a0de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 2, S("a0de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S(""), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S(""), 0, 1, S("ae"));
+    test(S("abcde"), 1, 3, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 2, S("a12e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 4, S("a1234e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 6, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e"));
+}
+
+void test9()
+{
+    test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 4, S("a2345e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 5, S("a2345e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 1, S("a3e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 2, S("a34e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 3, S("a345e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 4, S("a345e"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 1, S("a5e"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 2, S("a5e"));
+    test(S("abcde"), 1, 3, S("12345"), 5, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 5, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 11, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 4, S("a2345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 8, S("a23456789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 9, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 10, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 1, S("a6e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 2, S("a67e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 4, S("a6789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 5, S("a67890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 6, S("a67890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 1, S("a0e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 2, S("a0e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 10, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 10, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 21, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 9, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 18, S("a234567890123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 19, S("a2345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 20, S("a2345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 11, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 1, S("a0e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 2, S("a0e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S(""), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S(""), 0, 1, S("a"));
+    test(S("abcde"), 1, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 2, S("a12"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 4, S("a1234"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 6, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 2, S("a23"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 3, S("a234"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 5, S("a2345"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 1, S("a3"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 2, S("a34"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 3, S("a345"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 4, S("a345"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 1, S("a5"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 2, S("a5"));
+    test(S("abcde"), 1, 4, S("12345"), 5, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 5, 1, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890"));
+}
+
+void test10()
+{
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcde"), 1, 4, S("1234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 10, 1, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S(""), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S(""), 0, 1, S("a"));
+    test(S("abcde"), 1, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 2, S("a12"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 4, S("a1234"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 6, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 2, S("a23"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 3, S("a234"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 5, S("a2345"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 1, S("a3"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 2, S("a34"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 3, S("a345"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 4, S("a345"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 1, S("a5"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 2, S("a5"));
+    test(S("abcde"), 1, 5, S("12345"), 5, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 5, 1, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcde"), 1, 5, S("1234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 10, 1, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1"));
+}
+
+void test11()
+{
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 6, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 2, S("ab23cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 3, S("ab234cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 5, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 1, S("ab3cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 2, S("ab34cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 3, S("ab345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 4, S("ab345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 1, S("ab5cde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 2, S("ab5cde"));
+    test(S("abcde"), 2, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 8, S("ab23456789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 10, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 1, S("ab6cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 2, S("ab67cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 4, S("ab6789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 5, S("ab67890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 6, S("ab67890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 1, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 2, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 1, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 2, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S(""), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S(""), 0, 1, S("abde"));
+    test(S("abcde"), 2, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 2, S("ab12de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 6, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 2, S("ab23de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 3, S("ab234de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 4, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 5, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde"));
+}
+
+void test12()
+{
+    test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 2, S("ab34de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 3, S("ab345de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 4, S("ab345de"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 1, S("ab5de"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 2, S("ab5de"));
+    test(S("abcde"), 2, 1, S("12345"), 5, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 5, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 11, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 4, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 8, S("ab23456789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 9, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 10, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 1, S("ab6de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 2, S("ab67de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 4, S("ab6789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 5, S("ab67890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 6, S("ab67890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 1, S("ab0de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 2, S("ab0de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 10, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 10, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 21, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 9, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 18, S("ab234567890123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 19, S("ab2345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 20, S("ab2345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 11, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 1, S("ab0de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 2, S("ab0de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S(""), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S(""), 0, 1, S("abe"));
+    test(S("abcde"), 2, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 2, S("ab12e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 6, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 2, S("ab23e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 3, S("ab234e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 4, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 5, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 1, S("ab3e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 2, S("ab34e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 3, S("ab345e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 4, S("ab345e"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 1, S("ab5e"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 2, S("ab5e"));
+    test(S("abcde"), 2, 2, S("12345"), 5, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 5, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 11, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 4, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 8, S("ab23456789e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 9, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 10, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 1, S("ab6e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 2, S("ab67e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e"));
+}
+
+void test13()
+{
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 6, S("ab67890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 1, S("ab0e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 2, S("ab0e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 10, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 10, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 9, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 11, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 1, S("ab0e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 2, S("ab0e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S(""), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S(""), 0, 1, S("ab"));
+    test(S("abcde"), 2, 3, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 2, S("ab12"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 4, S("ab1234"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 6, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 2, S("ab23"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 3, S("ab234"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 5, S("ab2345"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 1, S("ab3"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 2, S("ab34"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 3, S("ab345"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 4, S("ab345"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 1, S("ab5"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 2, S("ab5"));
+    test(S("abcde"), 2, 3, S("12345"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 5, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 8, S("ab23456789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 10, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 1, S("ab6"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 2, S("ab67"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 4, S("ab6789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 5, S("ab67890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 6, S("ab67890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 1, S("ab0"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 2, S("ab0"));
+    test(S("abcde"), 2, 3, S("1234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 10, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+}
+
+void test14()
+{
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 1, S("ab0"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 2, S("ab0"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S(""), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S(""), 0, 1, S("ab"));
+    test(S("abcde"), 2, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 2, S("ab12"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 4, S("ab1234"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 6, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 2, S("ab23"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 3, S("ab234"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 5, S("ab2345"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 1, S("ab3"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 2, S("ab34"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 3, S("ab345"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 4, S("ab345"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 1, S("ab5"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 2, S("ab5"));
+    test(S("abcde"), 2, 4, S("12345"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 5, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 8, S("ab23456789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 10, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 1, S("ab6"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 2, S("ab67"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 4, S("ab6789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 5, S("ab67890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 6, S("ab67890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 1, S("ab0"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 2, S("ab0"));
+    test(S("abcde"), 2, 4, S("1234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 10, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 1, S("ab0"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 2, S("ab0"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 6, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 2, S("abcd23e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 3, S("abcd234e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 5, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 1, S("abcd3e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 2, S("abcd34e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 3, S("abcd345e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e"));
+}
+
+void test15()
+{
+    test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 4, 1, S("abcd5e"));
+    test(S("abcde"), 4, 0, S("12345"), 4, 2, S("abcd5e"));
+    test(S("abcde"), 4, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 8, S("abcd23456789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 10, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 1, S("abcd6e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 2, S("abcd67e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 4, S("abcd6789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 5, S("abcd67890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 6, S("abcd67890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 1, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 2, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 1, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 2, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S(""), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S(""), 0, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 2, S("abcd12"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 6, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 2, S("abcd23"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 3, S("abcd234"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 5, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 1, S("abcd3"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 2, S("abcd34"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 3, S("abcd345"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 4, S("abcd345"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 1, S("abcd5"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 2, S("abcd5"));
+    test(S("abcde"), 4, 1, S("12345"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 5, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 8, S("abcd23456789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 10, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 1, S("abcd6"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 2, S("abcd67"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 4, S("abcd6789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 5, S("abcd67890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 6, S("abcd67890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0"));
+}
+
+void test16()
+{
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0"));
+    test(S("abcde"), 4, 1, S("1234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 10, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 1, S("abcd0"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 2, S("abcd0"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S(""), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S(""), 0, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 2, S("abcd12"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 4, S("abcd1234"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 6, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 2, S("abcd23"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 3, S("abcd234"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 5, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 1, S("abcd3"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 2, S("abcd34"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 3, S("abcd345"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 4, S("abcd345"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 1, S("abcd5"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 2, S("abcd5"));
+    test(S("abcde"), 4, 2, S("12345"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 5, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 8, S("abcd23456789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 10, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 1, S("abcd6"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 2, S("abcd67"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 4, S("abcd6789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 5, S("abcd67890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 6, S("abcd67890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 1, S("abcd0"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 2, S("abcd0"));
+    test(S("abcde"), 4, 2, S("1234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 10, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 1, S("abcd0"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 2, S("abcd0"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd"));
+}
+
+void test17()
+{
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde"));
+}
+
+void test18()
+{
+    test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, 1, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+void test19()
+{
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 6, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 2, S("23abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 3, S("234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 5, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 1, S("3abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 2, S("34abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 3, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 4, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 1, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 2, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S(""), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij"));
+}
+
+void test20()
+{
+    test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 6, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 2, S("23bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 3, S("234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 4, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 5, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 1, S("3bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 2, S("34bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 3, S("345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 4, S("345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 1, S("5bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 2, S("5bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 5, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 5, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S(""), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S(""), 0, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 6, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 2, S("23fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 3, S("234fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 4, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 5, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 1, S("3fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 2, S("34fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 3, S("345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 4, S("345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 1, S("5fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 2, S("5fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 5, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 5, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij"));
+}
+
+void test21()
+{
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 11, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 4, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 8, S("23456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 9, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 10, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 1, S("6fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 2, S("67fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 4, S("6789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 5, S("67890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 6, S("67890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 1, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 2, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 1, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 2, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S(""), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S(""), 0, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 6, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 2, S("23j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 3, S("234j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 4, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 5, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 1, S("3j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 2, S("34j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 3, S("345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 4, S("345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 1, S("5j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 2, S("5j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 5, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 5, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 11, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 4, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 8, S("23456789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 9, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 10, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 1, S("6j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 2, S("67j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 4, S("6789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 5, S("67890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 6, S("67890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 1, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 2, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j"));
+}
+
+void test22()
+{
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 21, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 9, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 18, S("234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 19, S("2345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 20, S("2345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 11, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 1, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 2, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S(""), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S(""), 0, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 5, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S(""), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S(""), 0, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12"));
+}
+
+void test23()
+{
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 5, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 2, S("a23bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 3, S("a234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 1, S("a3bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 2, S("a34bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 3, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 4, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 1, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 2, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+}
+
+void test24()
+{
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S(""), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), 0, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 6, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 1, S("a2cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 2, S("a23cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 3, S("a234cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 4, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 5, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 1, S("a3cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 2, S("a34cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 3, S("a345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 4, S("a345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 1, S("a5cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 2, S("a5cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 5, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 5, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij"));
+}
+
+void test25()
+{
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S(""), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S(""), 0, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 6, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 2, S("a23fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 3, S("a234fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 4, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 5, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 1, S("a3fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 2, S("a34fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 3, S("a345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 4, S("a345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 1, S("a5fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 2, S("a5fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 5, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 5, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 11, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 4, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 8, S("a23456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 9, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 10, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 1, S("a6fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 2, S("a67fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 4, S("a6789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 5, S("a67890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 6, S("a67890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 1, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 2, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 1, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 2, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S(""), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S(""), 0, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 6, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj"));
+}
+
+void test26()
+{
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 2, S("a23j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 3, S("a234j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 4, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 5, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 1, S("a3j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 2, S("a34j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 3, S("a345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 4, S("a345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 1, S("a5j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 2, S("a5j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 5, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 5, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 11, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 4, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 8, S("a23456789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 9, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 10, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 1, S("a6j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 2, S("a67j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 4, S("a6789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 5, S("a67890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 6, S("a67890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 1, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 2, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 21, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 9, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 18, S("a234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 19, S("a2345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 20, S("a2345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 11, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 1, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 2, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S(""), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S(""), 0, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789"));
+}
+
+void test27()
+{
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S(""), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S(""), 0, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+}
+
+void test28()
+{
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 6, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 2, S("abcde23fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 3, S("abcde234fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 5, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 1, S("abcde3fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 2, S("abcde34fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 3, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 4, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 1, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 2, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 1, S("abcde6fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 2, S("abcde67fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 4, S("abcde6789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 5, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 6, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S(""), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S(""), 0, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 6, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 2, S("abcde23ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 3, S("abcde234ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij"));
+}
+
+void test29()
+{
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 1, S("abcde3ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 2, S("abcde34ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 3, S("abcde345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 4, S("abcde345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 1, S("abcde5ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 2, S("abcde5ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 5, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 4, S("abcde2345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 1, S("abcde6ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 2, S("abcde67ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 4, S("abcde6789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 5, S("abcde67890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 6, S("abcde67890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 1, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 2, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S(""), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S(""), 0, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 6, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 2, S("abcde23hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 3, S("abcde234hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 4, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 5, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 1, S("abcde3hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 2, S("abcde34hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 3, S("abcde345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 4, S("abcde345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 1, S("abcde5hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 2, S("abcde5hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 5, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 5, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 11, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 4, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 8, S("abcde23456789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 9, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 10, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij"));
+}
+
+void test30()
+{
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 4, S("abcde6789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 5, S("abcde67890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 6, S("abcde67890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 1, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 2, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 9, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 18, S("abcde234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 11, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 1, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 2, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S(""), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S(""), 0, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 2, S("abcde12j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 6, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 2, S("abcde23j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 3, S("abcde234j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 4, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 5, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 1, S("abcde3j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 2, S("abcde34j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 3, S("abcde345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 4, S("abcde345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 1, S("abcde5j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 2, S("abcde5j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 5, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 5, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 11, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 4, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 8, S("abcde23456789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 9, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 10, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 1, S("abcde6j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 2, S("abcde67j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 4, S("abcde6789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 5, S("abcde67890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 6, S("abcde67890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 1, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 2, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 9, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 18, S("abcde234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j"));
+}
+
+void test31()
+{
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 11, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 1, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 2, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S(""), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S(""), 0, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 5, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S(""), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S(""), 0, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34"));
+}
+
+void test32()
+{
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 5, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 6, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 2, S("abcdefghi23j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 3, S("abcdefghi234j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 5, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 1, S("abcdefghi3j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 2, S("abcdefghi34j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 3, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 4, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 1, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 2, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 1, S("abcdefghi6j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 2, S("abcdefghi67j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+}
+
+void test33()
+{
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S(""), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S(""), 0, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 6, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 2, S("abcdefghi23"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 3, S("abcdefghi234"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 5, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 1, S("abcdefghi3"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 2, S("abcdefghi34"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 3, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 4, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 1, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 2, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 5, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 1, S("abcdefghi6"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 2, S("abcdefghi67"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 4, S("abcdefghi6789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 5, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 6, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+}
+
+void test34()
+{
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S(""), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S(""), 0, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 6, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 2, S("abcdefghi23"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 3, S("abcdefghi234"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 5, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 1, S("abcdefghi3"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 2, S("abcdefghi34"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 3, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 4, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 1, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 2, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 5, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 1, S("abcdefghi6"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 2, S("abcdefghi67"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 4, S("abcdefghi6789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 5, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 6, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5"));
+}
+
+void test35()
+{
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij"));
+}
+
+void test36()
+{
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+void test37()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 6, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 2, S("23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 3, S("234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 4, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 5, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 1, S("3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 2, S("34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 3, S("345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 4, S("345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 1, S("5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 2, S("5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+void test38()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 6, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 2, S("23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 3, S("234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 4, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 5, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 1, S("3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 2, S("34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 3, S("345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 4, S("345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 1, S("5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 2, S("5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 11, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 4, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 8, S("23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 9, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 10, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 1, S("6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 2, S("67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 4, S("6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 5, S("67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 6, S("67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 1, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 2, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst"));
+}
+
+void test39()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 1, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 2, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 6, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 2, S("23t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 3, S("234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 4, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 5, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 1, S("3t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 2, S("34t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 3, S("345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 4, S("345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 1, S("5t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 2, S("5t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 11, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 4, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 8, S("23456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 9, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 10, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 1, S("6t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 2, S("67t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 4, S("6789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 5, S("67890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 6, S("67890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 1, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 2, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 21, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 9, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 18, S("234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 19, S("2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 20, S("2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 11, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 1, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 2, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S(""));
+}
+
+void test40()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789"));
+}
+
+void test41()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+}
+
+void test42()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 6, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 2, S("a23cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 3, S("a234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 4, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 5, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 1, S("a3cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 2, S("a34cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 3, S("a345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 4, S("a345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 1, S("a5cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 2, S("a5cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst"));
+}
+
+void test43()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 2, S("a23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 3, S("a234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 4, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 5, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 1, S("a3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 2, S("a34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 3, S("a345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 4, S("a345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 1, S("a5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 2, S("a5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 11, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 4, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 8, S("a23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 9, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 10, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 1, S("a6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 2, S("a67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 4, S("a6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 5, S("a67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 6, S("a67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 1, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 2, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 1, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 2, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 6, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 1, S("a2t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 2, S("a23t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 3, S("a234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 4, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 5, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 1, S("a3t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 2, S("a34t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 3, S("a345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 4, S("a345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 1, S("a5t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 2, S("a5t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 11, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t"));
+}
+
+void test44()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 8, S("a23456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 9, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 10, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 1, S("a6t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 2, S("a67t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 4, S("a6789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 5, S("a67890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 6, S("a67890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 1, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 2, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 21, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 1, S("a2t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 9, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 18, S("a234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 19, S("a2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 20, S("a2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 11, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 1, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 2, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+}
+
+void test45()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+}
+
+void test46()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 2, S("abcdefghij23lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 3, S("abcdefghij234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 1, S("abcdefghij3lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 2, S("abcdefghij34lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 3, S("abcdefghij345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 4, S("abcdefghij345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 1, S("abcdefghij5lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 2, S("abcdefghij5lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst"));
+}
+
+void test47()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 6, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 2, S("abcdefghij23pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 3, S("abcdefghij234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 4, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 5, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 1, S("abcdefghij3pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 2, S("abcdefghij34pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 3, S("abcdefghij345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 4, S("abcdefghij345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 1, S("abcdefghij5pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 2, S("abcdefghij5pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 11, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 4, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 8, S("abcdefghij23456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 10, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 1, S("abcdefghij6pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 2, S("abcdefghij67pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 4, S("abcdefghij6789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 5, S("abcdefghij67890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 6, S("abcdefghij67890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 1, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 2, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst"));
+}
+
+void test48()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 1, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 2, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 6, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 2, S("abcdefghij23t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 3, S("abcdefghij234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 4, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 5, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 1, S("abcdefghij3t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 2, S("abcdefghij34t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 3, S("abcdefghij345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 4, S("abcdefghij345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 1, S("abcdefghij5t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 2, S("abcdefghij5t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 11, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 4, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 8, S("abcdefghij23456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 9, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 10, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 1, S("abcdefghij6t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 2, S("abcdefghij67t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 4, S("abcdefghij6789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 5, S("abcdefghij67890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 6, S("abcdefghij67890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 1, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 2, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 9, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 1, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 2, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij"));
+}
+
+void test49()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789"));
+}
+
+void test50()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+}
+
+void test51()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+}
+
+void test52()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+}
+
+void test53()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+}
+
+void test54()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    test13();
+    test14();
+    test15();
+    test16();
+    test17();
+    test18();
+    test19();
+    test20();
+    test21();
+    test22();
+    test23();
+    test24();
+    test25();
+    test26();
+    test27();
+    test28();
+    test29();
+    test30();
+    test31();
+    test32();
+    test33();
+    test34();
+    test35();
+    test36();
+    test37();
+    test38();
+    test39();
+    test40();
+    test41();
+    test42();
+    test43();
+    test44();
+    test45();
+    test46();
+    test47();
+    test48();
+    test49();
+    test50();
+    test51();
+    test52();
+    test53();
+    test54();
+}
diff --git a/test/strings/basic.string/string.modifiers/string::swap/swap.pass.cpp b/test/strings/basic.string/string.modifiers/string::swap/swap.pass.cpp
new file mode 100644
index 0000000..a6d0468
--- /dev/null
+++ b/test/strings/basic.string/string.modifiers/string::swap/swap.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void swap(basic_string& s);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s1_ = s1;
+    S s2_ = s2;
+    s1.swap(s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s2_);
+    assert(s2 == s1_);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+}
diff --git a/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp b/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
new file mode 100644
index 0000000..5991c1c
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>& is,
+//           basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream in(" abc\n  def\n   ghij");
+        std::string s("initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        std::wistringstream in(L" abc\n  def\n   ghij");
+        std::wstring s(L"initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
new file mode 100644
index 0000000..97f4ffd
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>& is,
+//           basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream in(" abc*  def*   ghij");
+        std::string s("initial text");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s, '*');
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        std::wistringstream in(L" abc*  def*   ghij");
+        std::wstring s(L"initial text");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s, L'*');
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
new file mode 100644
index 0000000..cd9b711
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>&& is,
+//           basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("initial text");
+        getline(std::istringstream(" abc*  def*   ghij"), s, '*');
+        assert(s == " abc");
+    }
+    {
+        std::wstring s(L"initial text");
+        getline(std::wistringstream(L" abc*  def*   ghij"), s, L'*');
+        assert(s == L" abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
new file mode 100644
index 0000000..6541f46
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>&& is,
+//           basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s("initial text");
+        getline(std::istringstream(" abc\n  def\n   ghij"), s);
+        assert(s == " abc");
+    }
+    {
+        std::wstring s(L"initial text");
+        getline(std::wistringstream(L" abc\n  def\n   ghij"), s);
+        assert(s == L" abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
new file mode 100644
index 0000000..cf50090
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/stream_extract.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>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   operator>>(basic_istream<charT,traits>& is,
+//              basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream in("a bc defghij");
+        std::string s("initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == "a");
+        assert(in.peek() == ' ');
+        in >> s;
+        assert(in.good());
+        assert(s == "bc");
+        assert(in.peek() == ' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == "def");
+        assert(in.peek() == 'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == "ghij");
+        in >> s;
+        assert(in.fail());
+    }
+    {
+        std::wistringstream in(L"a bc defghij");
+        std::wstring s(L"initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == L"a");
+        assert(in.peek() == L' ');
+        in >> s;
+        assert(in.good());
+        assert(s == L"bc");
+        assert(in.peek() == L' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == L"def");
+        assert(in.peek() == L'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == L"ghij");
+        in >> s;
+        assert(in.fail());
+    }
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
new file mode 100644
index 0000000..d50c498
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os,
+//              const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream out;
+        std::string s("some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        std::ostringstream out;
+        std::string s("some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert("   " + s == out.str());
+    }
+    {
+        std::wostringstream out;
+        std::wstring s(L"some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        std::wostringstream out;
+        std::wstring s(L"some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert(L"   " + s == out.str());
+    }
+}
diff --git a/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
new file mode 100644
index 0000000..91ed562
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   void swap(basic_string<charT,traits,Allocator>& lhs, 
+//             basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s1_ = s1;
+    S s2_ = s2;
+    swap(s1, s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s2_);
+    assert(s2 == s1_);
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+}
diff --git "a/test/strings/basic.string/string.nonmembers/string::op\041=/pointer_string.pass.cpp" "b/test/strings/basic.string/string.nonmembers/string::op\041=/pointer_string.pass.cpp"
new file mode 100644
index 0000000..2c1d596
--- /dev/null
+++ "b/test/strings/basic.string/string.nonmembers/string::op\041=/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+}
diff --git "a/test/strings/basic.string/string.nonmembers/string::op\041=/string_pointer.pass.cpp" "b/test/strings/basic.string/string.nonmembers/string::op\041=/string_pointer.pass.cpp"
new file mode 100644
index 0000000..7c82fd7
--- /dev/null
+++ "b/test/strings/basic.string/string.nonmembers/string::op\041=/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+}
diff --git "a/test/strings/basic.string/string.nonmembers/string::op\041=/string_string.pass.cpp" "b/test/strings/basic.string/string.nonmembers/string::op\041=/string_string.pass.cpp"
new file mode 100644
index 0000000..5472626
--- /dev/null
+++ "b/test/strings/basic.string/string.nonmembers/string::op\041=/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator!=(const basic_string<charT,traits,Allocator>& lhs, 
+//                   const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::op+/char_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::op+/char_string.pass.cpp
new file mode 100644
index 0000000..0355616
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::op+/char_string.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator> 
+//   operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test0(typename S::value_type lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class S>
+void
+test1(typename S::value_type lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+#endif
+
+typedef std::string S;
+
+int main()
+{
+    test0('a', S(""), S("a"));
+    test0('a', S("12345"), S("a12345"));
+    test0('a', S("1234567890"), S("a1234567890"));
+    test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#ifdef _LIBCPP_MOVE
+
+    test1('a', S(""), S("a"));
+    test1('a', S("12345"), S("a12345"));
+    test1('a', S("1234567890"), S("a1234567890"));
+    test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::op+/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::op+/pointer_string.pass.cpp
new file mode 100644
index 0000000..9556770
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::op+/pointer_string.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator> 
+//   operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test0(const typename S::value_type* lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class S>
+void
+test1(const typename S::value_type* lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+#endif
+
+typedef std::string S;
+
+int main()
+{
+    test0("", S(""), S(""));
+    test0("", S("12345"), S("12345"));
+    test0("", S("1234567890"), S("1234567890"));
+    test0("", S("12345678901234567890"), S("12345678901234567890"));
+    test0("abcde", S(""), S("abcde"));
+    test0("abcde", S("12345"), S("abcde12345"));
+    test0("abcde", S("1234567890"), S("abcde1234567890"));
+    test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0("abcdefghij", S(""), S("abcdefghij"));
+    test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifdef _LIBCPP_MOVE
+
+    test1("", S(""), S(""));
+    test1("", S("12345"), S("12345"));
+    test1("", S("1234567890"), S("1234567890"));
+    test1("", S("12345678901234567890"), S("12345678901234567890"));
+    test1("abcde", S(""), S("abcde"));
+    test1("abcde", S("12345"), S("abcde12345"));
+    test1("abcde", S("1234567890"), S("abcde1234567890"));
+    test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1("abcdefghij", S(""), S("abcdefghij"));
+    test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::op+/string_char.pass.cpp b/test/strings/basic.string/string.nonmembers/string::op+/string_char.pass.cpp
new file mode 100644
index 0000000..2ac997d
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::op+/string_char.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test0(const S& lhs, typename S::value_type rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class S>
+void
+test1(S&& lhs, typename S::value_type rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+#endif
+
+typedef std::string S;
+
+int main()
+{
+    test0(S(""), '1', S("1"));
+    test0(S("abcde"), '1', S("abcde1"));
+    test0(S("abcdefghij"), '1', S("abcdefghij1"));
+    test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#ifdef _LIBCPP_MOVE
+
+    test1(S(""), '1', S("1"));
+    test1(S("abcde"), '1', S("abcde1"));
+    test1(S("abcdefghij"), '1', S("abcdefghij1"));
+    test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::op+/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::op+/string_pointer.pass.cpp
new file mode 100644
index 0000000..5487bc1
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::op+/string_pointer.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator> 
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test0(const S& lhs, const typename S::value_type* rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class S>
+void
+test1(S&& lhs, const typename S::value_type* rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+#endif
+
+typedef std::string S;
+
+int main()
+{
+    test0(S(""), "", S(""));
+    test0(S(""), "12345", S("12345"));
+    test0(S(""), "1234567890", S("1234567890"));
+    test0(S(""), "12345678901234567890", S("12345678901234567890"));
+    test0(S("abcde"), "", S("abcde"));
+    test0(S("abcde"), "12345", S("abcde12345"));
+    test0(S("abcde"), "1234567890", S("abcde1234567890"));
+    test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), "", S("abcdefghij"));
+    test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifdef _LIBCPP_MOVE
+
+    test1(S(""), "", S(""));
+    test1(S(""), "12345", S("12345"));
+    test1(S(""), "1234567890", S("1234567890"));
+    test1(S(""), "12345678901234567890", S("12345678901234567890"));
+    test1(S("abcde"), "", S("abcde"));
+    test1(S("abcde"), "12345", S("abcde12345"));
+    test1(S("abcde"), "1234567890", S("abcde1234567890"));
+    test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), "", S("abcdefghij"));
+    test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::op+/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::op+/string_string.pass.cpp
new file mode 100644
index 0000000..b9ab0de
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::op+/string_string.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator> 
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, 
+//             const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>&& lhs, 
+//             const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, 
+//             const basic_string<charT,traits,Allocator>&& rhs);
+
+// template<class charT, class traits, class Allocator> 
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>&& lhs, 
+//             const basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test0(const S& lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifdef _LIBCPP_MOVE
+
+template <class S>
+void
+test1(S&& lhs, const S& rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+template <class S>
+void
+test2(const S& lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+template <class S>
+void
+test3(S&& lhs, S&& rhs, const S& x)
+{
+    assert(move(lhs) + move(rhs) == x);
+}
+
+#endif
+
+typedef std::string S;
+
+int main()
+{
+    test0(S(""), S(""), S(""));
+    test0(S(""), S("12345"), S("12345"));
+    test0(S(""), S("1234567890"), S("1234567890"));
+    test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test0(S("abcde"), S(""), S("abcde"));
+    test0(S("abcde"), S("12345"), S("abcde12345"));
+    test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), S(""), S("abcdefghij"));
+    test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifdef _LIBCPP_MOVE
+
+    test1(S(""), S(""), S(""));
+    test1(S(""), S("12345"), S("12345"));
+    test1(S(""), S("1234567890"), S("1234567890"));
+    test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test1(S("abcde"), S(""), S("abcde"));
+    test1(S("abcde"), S("12345"), S("abcde12345"));
+    test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), S(""), S("abcdefghij"));
+    test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test2(S(""), S(""), S(""));
+    test2(S(""), S("12345"), S("12345"));
+    test2(S(""), S("1234567890"), S("1234567890"));
+    test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test2(S("abcde"), S(""), S("abcde"));
+    test2(S("abcde"), S("12345"), S("abcde12345"));
+    test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test2(S("abcdefghij"), S(""), S("abcdefghij"));
+    test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test3(S(""), S(""), S(""));
+    test3(S(""), S("12345"), S("12345"));
+    test3(S(""), S("1234567890"), S("1234567890"));
+    test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test3(S("abcde"), S(""), S("abcde"));
+    test3(S("abcde"), S("12345"), S("abcde12345"));
+    test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test3(S("abcdefghij"), S(""), S("abcdefghij"));
+    test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::operator==/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::operator==/pointer_string.pass.cpp
new file mode 100644
index 0000000..9fce864
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::operator==/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::operator==/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::operator==/string_pointer.pass.cpp
new file mode 100644
index 0000000..e365c80
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::operator==/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::operator==/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::operator==/string_string.pass.cpp
new file mode 100644
index 0000000..065c1ff
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::operator==/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator==(const basic_string<charT,traits,Allocator>& lhs, 
+//                   const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt/pointer_string.pass.cpp
new file mode 100644
index 0000000..8a0c10b
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), false);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt/string_pointer.pass.cpp
new file mode 100644
index 0000000..40f398e
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", false);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt/string_string.pass.cpp
new file mode 100644
index 0000000..3c5a50c
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>(const basic_string<charT,traits,Allocator>& lhs, 
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt=/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt=/pointer_string.pass.cpp
new file mode 100644
index 0000000..48df45b
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt=/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt=/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt=/string_pointer.pass.cpp
new file mode 100644
index 0000000..71f1896
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt=/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::opgt=/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::opgt=/string_string.pass.cpp
new file mode 100644
index 0000000..a2f76be
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::opgt=/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator>=(const basic_string<charT,traits,Allocator>& lhs, 
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt/pointer_string.pass.cpp
new file mode 100644
index 0000000..6e7eb43
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt/string_pointer.pass.cpp
new file mode 100644
index 0000000..0e7654e
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt/string_string.pass.cpp
new file mode 100644
index 0000000..4e3a7ad
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<(const basic_string<charT,traits,Allocator>& lhs, 
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt=/pointer_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt=/pointer_string.pass.cpp
new file mode 100644
index 0000000..7fe7d16
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt=/pointer_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test("", S(""), true);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt=/string_pointer.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt=/string_pointer.pass.cpp
new file mode 100644
index 0000000..9df54c7
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt=/string_pointer.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", true);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
diff --git a/test/strings/basic.string/string.nonmembers/string::oplt=/string_string.pass.cpp b/test/strings/basic.string/string.nonmembers/string::oplt=/string_string.pass.cpp
new file mode 100644
index 0000000..28e0c9c
--- /dev/null
+++ b/test/strings/basic.string/string.nonmembers/string::oplt=/string_string.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>
+
+// template<class charT, class traits, class Allocator> 
+//   bool operator<=(const basic_string<charT,traits,Allocator>& lhs, 
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
diff --git a/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp b/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp b/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
new file mode 100644
index 0000000..1a32acb
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* c_str() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typedef typename S::traits_type T;
+    const typename S::value_type* str = s.c_str();
+    if (s.size() > 0)
+    {
+        assert(T::compare(str, &s[0], s.size()) == 0);
+        assert(T::eq(str[s.size()], typename S::value_type()));
+    }
+    else
+        assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+}
diff --git a/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp b/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp
new file mode 100644
index 0000000..c4c9af6
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* data() const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s)
+{
+    typedef typename S::traits_type T;
+    const typename S::value_type* str = s.data();
+    if (s.size() > 0)
+    {
+        assert(T::compare(str, &s[0], s.size()) == 0);
+        assert(T::eq(str[s.size()], typename S::value_type()));
+    }
+    else
+        assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+}
diff --git a/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp b/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
new file mode 100644
index 0000000..b03debe
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// allocator_type get_allocator() const;
+
+#include <string>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::allocator_type& a)
+{
+    assert(s.get_allocator() == a);
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(""), A());
+    test(S("abcde", A(1)), A(1));
+    test(S("abcdefghij", A(2)), A(2));
+    test(S("abcdefghijklmnopqrst", A(3)), A(3));
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/pointer.pass.cpp b/test/strings/basic.string/string.ops/string::compare/pointer.pass.cpp
new file mode 100644
index 0000000..709478d
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/pointer.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const charT *s) const;
+
+#include <string>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, int x)
+{
+    assert(sign(s.compare(str)) == sign(x));
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", -5);
+    test(S(""), "abcdefghij", -10);
+    test(S(""), "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdefghij", -5);
+    test(S("abcde"), "abcdefghijklmnopqrst", -15);
+    test(S("abcdefghij"), "", 10);
+    test(S("abcdefghij"), "abcde", 5);
+    test(S("abcdefghij"), "abcdefghij", 0);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghijklmnopqrst"), "", 20);
+    test(S("abcdefghijklmnopqrst"), "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/size_size_pointer.pass.cpp b/test/strings/basic.string/string.ops/string::compare/size_size_pointer.pass.cpp
new file mode 100644
index 0000000..11894dc
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/size_size_pointer.pass.cpp
@@ -0,0 +1,358 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const typename S::value_type* str, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str)) == sign(x));
+        assert(pos1 <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), 0, 0, "", 0);
+    test(S(""), 0, 0, "abcde", -5);
+    test(S(""), 0, 0, "abcdefghij", -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S(""), 0, 1, "", 0);
+    test(S(""), 0, 1, "abcde", -5);
+    test(S(""), 0, 1, "abcdefghij", -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", -20);
+    test(S(""), 1, 0, "", 0);
+    test(S(""), 1, 0, "abcde", 0);
+    test(S(""), 1, 0, "abcdefghij", 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 0);
+    test(S("abcde"), 0, 0, "", 0);
+    test(S("abcde"), 0, 0, "abcde", -5);
+    test(S("abcde"), 0, 0, "abcdefghij", -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 0, 1, "", 1);
+    test(S("abcde"), 0, 1, "abcde", -4);
+    test(S("abcde"), 0, 1, "abcdefghij", -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcde"), 0, 2, "", 2);
+    test(S("abcde"), 0, 2, "abcde", -3);
+    test(S("abcde"), 0, 2, "abcdefghij", -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", -18);
+    test(S("abcde"), 0, 4, "", 4);
+    test(S("abcde"), 0, 4, "abcde", -1);
+    test(S("abcde"), 0, 4, "abcdefghij", -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", -16);
+    test(S("abcde"), 0, 5, "", 5);
+    test(S("abcde"), 0, 5, "abcde", 0);
+    test(S("abcde"), 0, 5, "abcdefghij", -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", -15);
+    test(S("abcde"), 0, 6, "", 5);
+    test(S("abcde"), 0, 6, "abcde", 0);
+    test(S("abcde"), 0, 6, "abcdefghij", -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", -15);
+    test(S("abcde"), 1, 0, "", 0);
+    test(S("abcde"), 1, 0, "abcde", -5);
+    test(S("abcde"), 1, 0, "abcdefghij", -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 1, 1, "", 1);
+    test(S("abcde"), 1, 1, "abcde", 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 2, "", 2);
+    test(S("abcde"), 1, 2, "abcde", 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 3, "", 3);
+    test(S("abcde"), 1, 3, "abcde", 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 4, "", 4);
+    test(S("abcde"), 1, 4, "abcde", 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 5, "", 4);
+    test(S("abcde"), 1, 5, "abcde", 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 2, 0, "", 0);
+    test(S("abcde"), 2, 0, "abcde", -5);
+    test(S("abcde"), 2, 0, "abcdefghij", -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 2, 1, "", 1);
+    test(S("abcde"), 2, 1, "abcde", 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 2, "", 2);
+    test(S("abcde"), 2, 2, "abcde", 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 3, "", 3);
+    test(S("abcde"), 2, 3, "abcde", 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 4, "", 3);
+    test(S("abcde"), 2, 4, "abcde", 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 4, 0, "", 0);
+    test(S("abcde"), 4, 0, "abcde", -5);
+    test(S("abcde"), 4, 0, "abcdefghij", -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 4, 1, "", 1);
+    test(S("abcde"), 4, 1, "abcde", 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 4);
+    test(S("abcde"), 4, 2, "", 1);
+    test(S("abcde"), 4, 2, "abcde", 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 4);
+    test(S("abcde"), 5, 0, "", 0);
+    test(S("abcde"), 5, 0, "abcde", -5);
+    test(S("abcde"), 5, 0, "abcdefghij", -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 5, 1, "", 0);
+    test(S("abcde"), 5, 1, "abcde", -5);
+    test(S("abcde"), 5, 1, "abcdefghij", -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+void test1()
+{
+    test(S("abcde"), 6, 0, "", 0);
+    test(S("abcde"), 6, 0, "abcde", 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghij"), 0, 0, "", 0);
+    test(S("abcdefghij"), 0, 0, "abcde", -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 0, 1, "", 1);
+    test(S("abcdefghij"), 0, 1, "abcde", -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcdefghij"), 0, 5, "", 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", -15);
+    test(S("abcdefghij"), 0, 9, "", 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", -11);
+    test(S("abcdefghij"), 0, 10, "", 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghij"), 0, 11, "", 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghij"), 1, 0, "", 0);
+    test(S("abcdefghij"), 1, 0, "abcde", -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 1, 1, "", 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 4, "", 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 8, "", 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 9, "", 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 10, "", 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 5, 0, "", 0);
+    test(S("abcdefghij"), 5, 0, "abcde", -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 5, 1, "", 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 2, "", 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 4, "", 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 5, "", 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 6, "", 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 9, 0, "", 0);
+    test(S("abcdefghij"), 9, 0, "abcde", -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 9, 1, "", 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 9);
+    test(S("abcdefghij"), 9, 2, "", 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 9);
+    test(S("abcdefghij"), 10, 0, "", 0);
+    test(S("abcdefghij"), 10, 0, "abcde", -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 10, 1, "", 0);
+    test(S("abcdefghij"), 10, 1, "abcde", -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 11, 0, "", 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/size_size_pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::compare/size_size_pointer_size.pass.cpp
new file mode 100644
index 0000000..1a30a9e
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1291 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s, size_type n2) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n1,
+     const typename S::value_type* str, typename S::size_type n2, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos, n1, str, n2)) == sign(x));
+        assert(pos <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > s.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), 0, 0, "", 0, 0);
+    test(S(""), 0, 0, "abcde", 0, 0);
+    test(S(""), 0, 0, "abcde", 1, -1);
+    test(S(""), 0, 0, "abcde", 2, -2);
+    test(S(""), 0, 0, "abcde", 4, -4);
+    test(S(""), 0, 0, "abcde", 5, -5);
+    test(S(""), 0, 0, "abcdefghij", 0, 0);
+    test(S(""), 0, 0, "abcdefghij", 1, -1);
+    test(S(""), 0, 0, "abcdefghij", 5, -5);
+    test(S(""), 0, 0, "abcdefghij", 9, -9);
+    test(S(""), 0, 0, "abcdefghij", 10, -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S(""), 0, 1, "", 0, 0);
+    test(S(""), 0, 1, "abcde", 0, 0);
+    test(S(""), 0, 1, "abcde", 1, -1);
+    test(S(""), 0, 1, "abcde", 2, -2);
+    test(S(""), 0, 1, "abcde", 4, -4);
+    test(S(""), 0, 1, "abcde", 5, -5);
+    test(S(""), 0, 1, "abcdefghij", 0, 0);
+    test(S(""), 0, 1, "abcdefghij", 1, -1);
+    test(S(""), 0, 1, "abcdefghij", 5, -5);
+    test(S(""), 0, 1, "abcdefghij", 9, -9);
+    test(S(""), 0, 1, "abcdefghij", 10, -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S(""), 1, 0, "", 0, 0);
+    test(S(""), 1, 0, "abcde", 0, 0);
+    test(S(""), 1, 0, "abcde", 1, 0);
+    test(S(""), 1, 0, "abcde", 2, 0);
+    test(S(""), 1, 0, "abcde", 4, 0);
+    test(S(""), 1, 0, "abcde", 5, 0);
+    test(S(""), 1, 0, "abcdefghij", 0, 0);
+    test(S(""), 1, 0, "abcdefghij", 1, 0);
+    test(S(""), 1, 0, "abcdefghij", 5, 0);
+    test(S(""), 1, 0, "abcdefghij", 9, 0);
+    test(S(""), 1, 0, "abcdefghij", 10, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcde"), 0, 0, "", 0, 0);
+    test(S("abcde"), 0, 0, "abcde", 0, 0);
+    test(S("abcde"), 0, 0, "abcde", 1, -1);
+    test(S("abcde"), 0, 0, "abcde", 2, -2);
+    test(S("abcde"), 0, 0, "abcde", 4, -4);
+    test(S("abcde"), 0, 0, "abcde", 5, -5);
+    test(S("abcde"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 0, 1, "", 0, 1);
+    test(S("abcde"), 0, 1, "abcde", 0, 1);
+    test(S("abcde"), 0, 1, "abcde", 1, 0);
+    test(S("abcde"), 0, 1, "abcde", 2, -1);
+    test(S("abcde"), 0, 1, "abcde", 4, -3);
+    test(S("abcde"), 0, 1, "abcde", 5, -4);
+    test(S("abcde"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcde"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcde"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcde"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcde"), 0, 2, "", 0, 2);
+    test(S("abcde"), 0, 2, "abcde", 0, 2);
+    test(S("abcde"), 0, 2, "abcde", 1, 1);
+    test(S("abcde"), 0, 2, "abcde", 2, 0);
+    test(S("abcde"), 0, 2, "abcde", 4, -2);
+    test(S("abcde"), 0, 2, "abcde", 5, -3);
+    test(S("abcde"), 0, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 0, 2, "abcdefghij", 1, 1);
+    test(S("abcde"), 0, 2, "abcdefghij", 5, -3);
+    test(S("abcde"), 0, 2, "abcdefghij", 9, -7);
+    test(S("abcde"), 0, 2, "abcdefghij", 10, -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 10, -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 19, -17);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 20, -18);
+    test(S("abcde"), 0, 4, "", 0, 4);
+    test(S("abcde"), 0, 4, "abcde", 0, 4);
+    test(S("abcde"), 0, 4, "abcde", 1, 3);
+    test(S("abcde"), 0, 4, "abcde", 2, 2);
+}
+
+void test1()
+{
+    test(S("abcde"), 0, 4, "abcde", 4, 0);
+    test(S("abcde"), 0, 4, "abcde", 5, -1);
+    test(S("abcde"), 0, 4, "abcdefghij", 0, 4);
+    test(S("abcde"), 0, 4, "abcdefghij", 1, 3);
+    test(S("abcde"), 0, 4, "abcdefghij", 5, -1);
+    test(S("abcde"), 0, 4, "abcdefghij", 9, -5);
+    test(S("abcde"), 0, 4, "abcdefghij", 10, -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 1, 3);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 10, -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 19, -15);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 20, -16);
+    test(S("abcde"), 0, 5, "", 0, 5);
+    test(S("abcde"), 0, 5, "abcde", 0, 5);
+    test(S("abcde"), 0, 5, "abcde", 1, 4);
+    test(S("abcde"), 0, 5, "abcde", 2, 3);
+    test(S("abcde"), 0, 5, "abcde", 4, 1);
+    test(S("abcde"), 0, 5, "abcde", 5, 0);
+    test(S("abcde"), 0, 5, "abcdefghij", 0, 5);
+    test(S("abcde"), 0, 5, "abcdefghij", 1, 4);
+    test(S("abcde"), 0, 5, "abcdefghij", 5, 0);
+    test(S("abcde"), 0, 5, "abcdefghij", 9, -4);
+    test(S("abcde"), 0, 5, "abcdefghij", 10, -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcde"), 0, 6, "", 0, 5);
+    test(S("abcde"), 0, 6, "abcde", 0, 5);
+    test(S("abcde"), 0, 6, "abcde", 1, 4);
+    test(S("abcde"), 0, 6, "abcde", 2, 3);
+    test(S("abcde"), 0, 6, "abcde", 4, 1);
+    test(S("abcde"), 0, 6, "abcde", 5, 0);
+    test(S("abcde"), 0, 6, "abcdefghij", 0, 5);
+    test(S("abcde"), 0, 6, "abcdefghij", 1, 4);
+    test(S("abcde"), 0, 6, "abcdefghij", 5, 0);
+    test(S("abcde"), 0, 6, "abcdefghij", 9, -4);
+    test(S("abcde"), 0, 6, "abcdefghij", 10, -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcde"), 1, 0, "", 0, 0);
+    test(S("abcde"), 1, 0, "abcde", 0, 0);
+    test(S("abcde"), 1, 0, "abcde", 1, -1);
+    test(S("abcde"), 1, 0, "abcde", 2, -2);
+    test(S("abcde"), 1, 0, "abcde", 4, -4);
+    test(S("abcde"), 1, 0, "abcde", 5, -5);
+    test(S("abcde"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 1, 1, "", 0, 1);
+    test(S("abcde"), 1, 1, "abcde", 0, 1);
+    test(S("abcde"), 1, 1, "abcde", 1, 1);
+    test(S("abcde"), 1, 1, "abcde", 2, 1);
+    test(S("abcde"), 1, 1, "abcde", 4, 1);
+    test(S("abcde"), 1, 1, "abcde", 5, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 2, "", 0, 2);
+    test(S("abcde"), 1, 2, "abcde", 0, 2);
+    test(S("abcde"), 1, 2, "abcde", 1, 1);
+    test(S("abcde"), 1, 2, "abcde", 2, 1);
+    test(S("abcde"), 1, 2, "abcde", 4, 1);
+    test(S("abcde"), 1, 2, "abcde", 5, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 1, 2, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 3, "", 0, 3);
+    test(S("abcde"), 1, 3, "abcde", 0, 3);
+    test(S("abcde"), 1, 3, "abcde", 1, 1);
+    test(S("abcde"), 1, 3, "abcde", 2, 1);
+    test(S("abcde"), 1, 3, "abcde", 4, 1);
+    test(S("abcde"), 1, 3, "abcde", 5, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 0, 3);
+    test(S("abcde"), 1, 3, "abcdefghij", 1, 1);
+}
+
+void test2()
+{
+    test(S("abcde"), 1, 3, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 0, 3);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 4, "", 0, 4);
+    test(S("abcde"), 1, 4, "abcde", 0, 4);
+    test(S("abcde"), 1, 4, "abcde", 1, 1);
+    test(S("abcde"), 1, 4, "abcde", 2, 1);
+    test(S("abcde"), 1, 4, "abcde", 4, 1);
+    test(S("abcde"), 1, 4, "abcde", 5, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 0, 4);
+    test(S("abcde"), 1, 4, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 5, "", 0, 4);
+    test(S("abcde"), 1, 5, "abcde", 0, 4);
+    test(S("abcde"), 1, 5, "abcde", 1, 1);
+    test(S("abcde"), 1, 5, "abcde", 2, 1);
+    test(S("abcde"), 1, 5, "abcde", 4, 1);
+    test(S("abcde"), 1, 5, "abcde", 5, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 0, 4);
+    test(S("abcde"), 1, 5, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 2, 0, "", 0, 0);
+    test(S("abcde"), 2, 0, "abcde", 0, 0);
+    test(S("abcde"), 2, 0, "abcde", 1, -1);
+    test(S("abcde"), 2, 0, "abcde", 2, -2);
+    test(S("abcde"), 2, 0, "abcde", 4, -4);
+    test(S("abcde"), 2, 0, "abcde", 5, -5);
+    test(S("abcde"), 2, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 2, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 2, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 2, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 2, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 2, 1, "", 0, 1);
+    test(S("abcde"), 2, 1, "abcde", 0, 1);
+    test(S("abcde"), 2, 1, "abcde", 1, 2);
+    test(S("abcde"), 2, 1, "abcde", 2, 2);
+    test(S("abcde"), 2, 1, "abcde", 4, 2);
+    test(S("abcde"), 2, 1, "abcde", 5, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 2, 1, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 2, "", 0, 2);
+    test(S("abcde"), 2, 2, "abcde", 0, 2);
+    test(S("abcde"), 2, 2, "abcde", 1, 2);
+    test(S("abcde"), 2, 2, "abcde", 2, 2);
+    test(S("abcde"), 2, 2, "abcde", 4, 2);
+    test(S("abcde"), 2, 2, "abcde", 5, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 3, "", 0, 3);
+    test(S("abcde"), 2, 3, "abcde", 0, 3);
+    test(S("abcde"), 2, 3, "abcde", 1, 2);
+    test(S("abcde"), 2, 3, "abcde", 2, 2);
+    test(S("abcde"), 2, 3, "abcde", 4, 2);
+    test(S("abcde"), 2, 3, "abcde", 5, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 0, 3);
+    test(S("abcde"), 2, 3, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 0, 3);
+}
+
+void test3()
+{
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 4, "", 0, 3);
+    test(S("abcde"), 2, 4, "abcde", 0, 3);
+    test(S("abcde"), 2, 4, "abcde", 1, 2);
+    test(S("abcde"), 2, 4, "abcde", 2, 2);
+    test(S("abcde"), 2, 4, "abcde", 4, 2);
+    test(S("abcde"), 2, 4, "abcde", 5, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 0, 3);
+    test(S("abcde"), 2, 4, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 0, 3);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 4, 0, "", 0, 0);
+    test(S("abcde"), 4, 0, "abcde", 0, 0);
+    test(S("abcde"), 4, 0, "abcde", 1, -1);
+    test(S("abcde"), 4, 0, "abcde", 2, -2);
+    test(S("abcde"), 4, 0, "abcde", 4, -4);
+    test(S("abcde"), 4, 0, "abcde", 5, -5);
+    test(S("abcde"), 4, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 4, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 4, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 4, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 4, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 4, 1, "", 0, 1);
+    test(S("abcde"), 4, 1, "abcde", 0, 1);
+    test(S("abcde"), 4, 1, "abcde", 1, 4);
+    test(S("abcde"), 4, 1, "abcde", 2, 4);
+    test(S("abcde"), 4, 1, "abcde", 4, 4);
+    test(S("abcde"), 4, 1, "abcde", 5, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 4, 1, "abcdefghij", 1, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 5, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 9, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 10, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 10, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 19, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 20, 4);
+    test(S("abcde"), 4, 2, "", 0, 1);
+    test(S("abcde"), 4, 2, "abcde", 0, 1);
+    test(S("abcde"), 4, 2, "abcde", 1, 4);
+    test(S("abcde"), 4, 2, "abcde", 2, 4);
+    test(S("abcde"), 4, 2, "abcde", 4, 4);
+    test(S("abcde"), 4, 2, "abcde", 5, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 0, 1);
+    test(S("abcde"), 4, 2, "abcdefghij", 1, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 5, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 9, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 10, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 10, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 19, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 20, 4);
+    test(S("abcde"), 5, 0, "", 0, 0);
+    test(S("abcde"), 5, 0, "abcde", 0, 0);
+    test(S("abcde"), 5, 0, "abcde", 1, -1);
+    test(S("abcde"), 5, 0, "abcde", 2, -2);
+    test(S("abcde"), 5, 0, "abcde", 4, -4);
+    test(S("abcde"), 5, 0, "abcde", 5, -5);
+    test(S("abcde"), 5, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 5, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 5, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 5, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 5, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 5, 1, "", 0, 0);
+    test(S("abcde"), 5, 1, "abcde", 0, 0);
+    test(S("abcde"), 5, 1, "abcde", 1, -1);
+    test(S("abcde"), 5, 1, "abcde", 2, -2);
+    test(S("abcde"), 5, 1, "abcde", 4, -4);
+    test(S("abcde"), 5, 1, "abcde", 5, -5);
+    test(S("abcde"), 5, 1, "abcdefghij", 0, 0);
+    test(S("abcde"), 5, 1, "abcdefghij", 1, -1);
+    test(S("abcde"), 5, 1, "abcdefghij", 5, -5);
+    test(S("abcde"), 5, 1, "abcdefghij", 9, -9);
+    test(S("abcde"), 5, 1, "abcdefghij", 10, -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 20, -20);
+}
+
+void test4()
+{
+    test(S("abcde"), 6, 0, "", 0, 0);
+    test(S("abcde"), 6, 0, "abcde", 0, 0);
+    test(S("abcde"), 6, 0, "abcde", 1, 0);
+    test(S("abcde"), 6, 0, "abcde", 2, 0);
+    test(S("abcde"), 6, 0, "abcde", 4, 0);
+    test(S("abcde"), 6, 0, "abcde", 5, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 1, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 5, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 9, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 10, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghij"), 0, 0, "", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 0, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 0, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 0, 1, "", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcde", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcde", 2, -1);
+    test(S("abcdefghij"), 0, 1, "abcde", 4, -3);
+    test(S("abcdefghij"), 0, 1, "abcde", 5, -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcdefghij"), 0, 5, "", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcde", 2, 3);
+    test(S("abcdefghij"), 0, 5, "abcde", 4, 1);
+    test(S("abcdefghij"), 0, 5, "abcde", 5, 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 5, 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 9, -4);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 10, -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcdefghij"), 0, 9, "", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcde", 2, 7);
+    test(S("abcdefghij"), 0, 9, "abcde", 4, 5);
+    test(S("abcdefghij"), 0, 9, "abcde", 5, 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 5, 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 9, 0);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 10, -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 10, -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 19, -10);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 20, -11);
+    test(S("abcdefghij"), 0, 10, "", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcde", 2, 8);
+    test(S("abcdefghij"), 0, 10, "abcde", 4, 6);
+    test(S("abcdefghij"), 0, 10, "abcde", 5, 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghij"), 0, 11, "", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcde", 2, 8);
+}
+
+void test5()
+{
+    test(S("abcdefghij"), 0, 11, "abcde", 4, 6);
+    test(S("abcdefghij"), 0, 11, "abcde", 5, 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghij"), 1, 0, "", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 1, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 1, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 1, 1, "", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 4, "", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 8, "", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 9, "", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 10, "", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 1, 1);
+}
+
+void test6()
+{
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 5, 0, "", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 5, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 5, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 5, 1, "", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 2, "", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 4, "", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 5, "", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 6, "", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 0, 5);
+}
+
+void test7()
+{
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 9, 0, "", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 9, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 9, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 9, 1, "", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 2, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 4, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 5, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 5, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 9, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 10, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 19, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 20, 9);
+    test(S("abcdefghij"), 9, 2, "", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 2, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 4, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 5, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 5, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 9, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 10, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 19, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 20, 9);
+    test(S("abcdefghij"), 10, 0, "", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 10, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 10, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 10, 1, "", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcde", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcde", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcde", 2, -2);
+    test(S("abcdefghij"), 10, 1, "abcde", 4, -4);
+    test(S("abcdefghij"), 10, 1, "abcde", 5, -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 11, 0, "", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 2, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 4, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 5, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 5, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 9, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 2, 8);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 4, 6);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 2, 17);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 4, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 2, -2);
+}
+
+void test9()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 1, -1);
+}
+
+void test10()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 0, 0);
+}
+
+void test11()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 20, 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/size_size_string.pass.cpp b/test/strings/basic.string/string.ops/string::compare/size_size_string.pass.cpp
new file mode 100644
index 0000000..9eeb2d5
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/size_size_string.pass.cpp
@@ -0,0 +1,358 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const S& str, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str)) == sign(x));
+        assert(pos1 <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0);
+    test(S(""), 0, 0, S("abcde"), -5);
+    test(S(""), 0, 0, S("abcdefghij"), -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S(""), 0, 1, S(""), 0);
+    test(S(""), 0, 1, S("abcde"), -5);
+    test(S(""), 0, 1, S("abcdefghij"), -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S(""), 1, 0, S(""), 0);
+    test(S(""), 1, 0, S("abcde"), 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcde"), 0, 0, S(""), 0);
+    test(S("abcde"), 0, 0, S("abcde"), -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 0, 1, S(""), 1);
+    test(S("abcde"), 0, 1, S("abcde"), -4);
+    test(S("abcde"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcde"), 0, 2, S(""), 2);
+    test(S("abcde"), 0, 2, S("abcde"), -3);
+    test(S("abcde"), 0, 2, S("abcdefghij"), -8);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), -18);
+    test(S("abcde"), 0, 4, S(""), 4);
+    test(S("abcde"), 0, 4, S("abcde"), -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), -6);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), -16);
+    test(S("abcde"), 0, 5, S(""), 5);
+    test(S("abcde"), 0, 5, S("abcde"), 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), -5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcde"), 0, 6, S(""), 5);
+    test(S("abcde"), 0, 6, S("abcde"), 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), -5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcde"), 1, 0, S(""), 0);
+    test(S("abcde"), 1, 0, S("abcde"), -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 1, 1, S(""), 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 2, S(""), 2);
+    test(S("abcde"), 1, 2, S("abcde"), 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 3, S(""), 3);
+    test(S("abcde"), 1, 3, S("abcde"), 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 4, S(""), 4);
+    test(S("abcde"), 1, 4, S("abcde"), 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 5, S(""), 4);
+    test(S("abcde"), 1, 5, S("abcde"), 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 2, 0, S(""), 0);
+    test(S("abcde"), 2, 0, S("abcde"), -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 2, 1, S(""), 1);
+    test(S("abcde"), 2, 1, S("abcde"), 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 2, S(""), 2);
+    test(S("abcde"), 2, 2, S("abcde"), 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 3, S(""), 3);
+    test(S("abcde"), 2, 3, S("abcde"), 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 4, S(""), 3);
+    test(S("abcde"), 2, 4, S("abcde"), 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 4, 0, S(""), 0);
+    test(S("abcde"), 4, 0, S("abcde"), -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 4, 1, S(""), 1);
+    test(S("abcde"), 4, 1, S("abcde"), 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 4);
+    test(S("abcde"), 4, 2, S(""), 1);
+    test(S("abcde"), 4, 2, S("abcde"), 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 4);
+    test(S("abcde"), 5, 0, S(""), 0);
+    test(S("abcde"), 5, 0, S("abcde"), -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 5, 1, S(""), 0);
+    test(S("abcde"), 5, 1, S("abcde"), -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), -20);
+}
+
+void test1()
+{
+    test(S("abcde"), 6, 0, S(""), 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 0, 1, S(""), 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), -4);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcdefghij"), 0, 5, S(""), 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcdefghij"), 0, 9, S(""), 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), -11);
+    test(S("abcdefghij"), 0, 10, S(""), 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghij"), 0, 11, S(""), 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghij"), 1, 0, S(""), 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 1, 1, S(""), 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 4, S(""), 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 8, S(""), 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 9, S(""), 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 10, S(""), 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 5, 0, S(""), 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 5, 1, S(""), 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 2, S(""), 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 4, S(""), 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 5, S(""), 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 6, S(""), 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 9, 0, S(""), 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 9, 1, S(""), 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 9);
+    test(S("abcdefghij"), 9, 2, S(""), 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 9);
+    test(S("abcdefghij"), 10, 0, S(""), 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 10, 1, S(""), 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 11, 0, S(""), 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/size_size_string_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::compare/size_size_string_size_size.pass.cpp
new file mode 100644
index 0000000..8a6be68
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5800 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str,
+//             size_type pos2, size_type n2) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
+        assert(pos1 <= s.size());
+        assert(pos2 <= str.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size() || pos2 > str.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0, 0, 0);
+    test(S(""), 0, 0, S(""), 0, 1, 0);
+    test(S(""), 0, 0, S(""), 1, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 0, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 0, 4, -4);
+    test(S(""), 0, 0, S("abcde"), 0, 5, -5);
+    test(S(""), 0, 0, S("abcde"), 0, 6, -5);
+    test(S(""), 0, 0, S("abcde"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 1, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 1, 3, -3);
+    test(S(""), 0, 0, S("abcde"), 1, 4, -4);
+    test(S(""), 0, 0, S("abcde"), 1, 5, -4);
+    test(S(""), 0, 0, S("abcde"), 2, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 2, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 2, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 2, 3, -3);
+    test(S(""), 0, 0, S("abcde"), 2, 4, -3);
+    test(S(""), 0, 0, S("abcde"), 4, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 4, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 4, 2, -1);
+    test(S(""), 0, 0, S("abcde"), 5, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 5, 1, 0);
+    test(S(""), 0, 0, S("abcde"), 6, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S(""), 0, 1, S(""), 0, 0, 0);
+    test(S(""), 0, 1, S(""), 0, 1, 0);
+    test(S(""), 0, 1, S(""), 1, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 0, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 0, 4, -4);
+    test(S(""), 0, 1, S("abcde"), 0, 5, -5);
+    test(S(""), 0, 1, S("abcde"), 0, 6, -5);
+    test(S(""), 0, 1, S("abcde"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 1, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 1, 3, -3);
+    test(S(""), 0, 1, S("abcde"), 1, 4, -4);
+    test(S(""), 0, 1, S("abcde"), 1, 5, -4);
+    test(S(""), 0, 1, S("abcde"), 2, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 2, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 2, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 2, 3, -3);
+    test(S(""), 0, 1, S("abcde"), 2, 4, -3);
+    test(S(""), 0, 1, S("abcde"), 4, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 4, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 4, 2, -1);
+    test(S(""), 0, 1, S("abcde"), 5, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 5, 1, 0);
+    test(S(""), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+void test1()
+{
+    test(S(""), 0, 1, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 5, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 9, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 10, -10);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 11, -10);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 4, -4);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 8, -8);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 9, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 10, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 2, -2);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 4, -4);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 2, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S(""), 1, 0, S(""), 0, 0, 0);
+    test(S(""), 1, 0, S(""), 0, 1, 0);
+    test(S(""), 1, 0, S(""), 1, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 5, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 6, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 3, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 5, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 3, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 5, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 5, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 6, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 5, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 9, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 10, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 11, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 4, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 8, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 9, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 10, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 2, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 4, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 5, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 6, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 2, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+}
+
+void test2()
+{
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 0, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 0, 1);
+}
+
+void test3()
+{
+    test(S("abcde"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 0, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 0, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 2, 0);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 4, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 5, -3);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 6, -3);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 5, -3);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 9, -7);
+}
+
+void test4()
+{
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 10, -8);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 11, -8);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 10, -8);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 19, -17);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 20, -18);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 21, -18);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 4, S(""), 0, 0, 4);
+    test(S("abcde"), 0, 4, S(""), 0, 1, 4);
+    test(S("abcde"), 0, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 4, 0);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 5, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 6, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 4, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 5, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 9, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 10, -6);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 11, -6);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 10, -6);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 19, -15);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 20, -16);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 21, -16);
+}
+
+void test5()
+{
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 5, S(""), 0, 0, 5);
+    test(S("abcde"), 0, 5, S(""), 0, 1, 5);
+    test(S("abcde"), 0, 5, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 2, 3);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 5, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 5, S("abcde"), 5, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 5, 1, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 9, -4);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 10, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 11, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 6, S(""), 0, 0, 5);
+    test(S("abcde"), 0, 6, S(""), 0, 1, 5);
+    test(S("abcde"), 0, 6, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 2, 3);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 5, 0);
+}
+
+void test6()
+{
+    test(S("abcde"), 0, 6, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 6, S("abcde"), 5, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 5, 1, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 9, -4);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 10, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 11, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 10, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 10, 1, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 1, -1);
+}
+
+void test7()
+{
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+}
+
+void test8()
+{
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 1, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 1, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 2, 0);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 4, -2);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 5, -2);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 4, -2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 8, -6);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 9, -7);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 10, -7);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 9, -7);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 18, -16);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 19, -17);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 20, -17);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 3, S(""), 0, 0, 3);
+    test(S("abcde"), 1, 3, S(""), 0, 1, 3);
+    test(S("abcde"), 1, 3, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 2, 1);
+}
+
+void test9()
+{
+    test(S("abcde"), 1, 3, S("abcde"), 1, 3, 0);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 3, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 8, -5);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 9, -6);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 10, -6);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 9, -6);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 18, -15);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 19, -16);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 20, -16);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 4, S(""), 0, 0, 4);
+    test(S("abcde"), 1, 4, S(""), 0, 1, 4);
+    test(S("abcde"), 1, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 2, 2);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 4, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 8, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 9, -5);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 10, -5);
+}
+
+void test10()
+{
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 5, S(""), 0, 0, 4);
+    test(S("abcde"), 1, 5, S(""), 0, 1, 4);
+    test(S("abcde"), 1, 5, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 2, 2);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 5, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 8, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 9, -5);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 10, -5);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 1, -9);
+}
+
+void test11()
+{
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 2, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 2, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 2, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 2, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 0, 1);
+}
+
+void test12()
+{
+    test(S("abcde"), 2, 1, S("abcde"), 2, 1, 0);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 2, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 2, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 1, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 2, 0);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 4, -3);
+}
+
+void test13()
+{
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 3, S(""), 0, 0, 3);
+    test(S("abcde"), 2, 3, S(""), 0, 1, 3);
+    test(S("abcde"), 2, 3, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 2, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 3, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 11, -8);
+}
+
+void test14()
+{
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 4, S(""), 0, 0, 3);
+    test(S("abcde"), 2, 4, S(""), 0, 1, 3);
+    test(S("abcde"), 2, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 2, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 4, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 4, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 4, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 4, -3);
+}
+
+void test15()
+{
+    test(S("abcde"), 4, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 4, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 4, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 2, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 4, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 5, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 6, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 2, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 3, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 4, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 5, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 2, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 3, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 4, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 5, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 9, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 10, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 11, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 4, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 8, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 9, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 10, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 2, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 4, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 5, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 6, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 1, -5);
+}
+
+void test16()
+{
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 2, -5);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 10, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 19, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 20, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 21, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 9, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 18, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 19, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 20, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 1, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 5, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 9, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 10, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 11, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 1, -15);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 2, -15);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 2, S(""), 0, 0, 1);
+    test(S("abcde"), 4, 2, S(""), 0, 1, 1);
+    test(S("abcde"), 4, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 2, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 4, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 5, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 6, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 2, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 3, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 4, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 5, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 2, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 3, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 4, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 5, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 9, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 10, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 11, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 4, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 8, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 9, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 10, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 2, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 4, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 5, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 6, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 1, -5);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 2, -5);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 10, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 19, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 20, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 21, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 9, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 18, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 19, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 20, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 1, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 5, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 9, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 10, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 11, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 1, -15);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 2, -15);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+}
+
+void test17()
+{
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 5, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 5, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 5, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 5, 1, S(""), 0, 0, 0);
+    test(S("abcde"), 5, 1, S(""), 0, 1, 0);
+    test(S("abcde"), 5, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 5, 0, 0);
+}
+
+void test18()
+{
+    test(S("abcde"), 5, 1, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 6, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 6, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 6, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 5, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 3, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 11, 0, 0);
+}
+
+void test19()
+{
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S(""), 0, 1, 1);
+}
+
+void test20()
+{
+    test(S("abcdefghij"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 5, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 0, 5, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 1, 4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 2, 3);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 5, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 6, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 1, 4);
+}
+
+void test21()
+{
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 9, -4);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 10, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 11, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 9, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 0, 9, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 2, 7);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 5, 4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 6, 4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 5, 4);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 11, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 19, -10);
+}
+
+void test22()
+{
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 20, -11);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 21, -11);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 10, S(""), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S(""), 0, 1, 10);
+    test(S("abcdefghij"), 0, 10, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 2, 8);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 4, 6);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 11, S(""), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S(""), 0, 1, 10);
+    test(S("abcdefghij"), 0, 11, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 2, 8);
+}
+
+void test23()
+{
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 4, 6);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 11, -10);
+}
+
+void test24()
+{
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+}
+
+void test25()
+{
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 4, S(""), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S(""), 0, 1, 4);
+    test(S("abcdefghij"), 1, 4, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 2, 2);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 3, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 4, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 5, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 5, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 5, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 8, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 9, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 10, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 8, S(""), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S(""), 0, 1, 8);
+    test(S("abcdefghij"), 1, 8, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 0, 8);
+}
+
+void test26()
+{
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 2, 6);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 3, 5);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 5, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 5, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 18, -10);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 19, -11);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 20, -11);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 9, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 1, 9, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 2, 7);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 3, 6);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 5, 5);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 8, 1);
+}
+
+void test27()
+{
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 10, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 1, 10, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 2, 7);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 3, 6);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 5, 5);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 8, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 20, -10);
+}
+
+void test28()
+{
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 5, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 4, 4);
+}
+
+void test29()
+{
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 2, -1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 4, -3);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 2, S(""), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S(""), 0, 1, 2);
+    test(S("abcdefghij"), 5, 2, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 1, 1);
+}
+
+void test30()
+{
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 4, -2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 5, -3);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 6, -3);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 4, S(""), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S(""), 0, 1, 4);
+    test(S("abcdefghij"), 5, 4, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 1, 3);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 2, 2);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 5, -1);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 6, -1);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 9, -5);
+}
+
+void test31()
+{
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 5, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 2, 3);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 4, 1);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 6, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 2, 3);
+}
+
+void test32()
+{
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 2, 3);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 4, 1);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 6, -5);
+}
+
+void test33()
+{
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 9, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 2, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 4, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 6, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 2, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 3, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 5, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 1, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 2, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 3, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 4, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 1, 5);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 2, 5);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 9, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 8, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 10, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 2, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 4, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 5, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 6, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 19, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 20, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 21, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 18, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 19, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 20, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 5, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 9, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 1, -10);
+}
+
+void test34()
+{
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 2, -10);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 2, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 9, 2, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 2, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 4, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 6, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 2, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 3, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 5, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 1, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 2, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 3, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 4, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 1, 5);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 2, 5);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 9, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 8, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 10, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 2, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 4, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 5, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 6, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 19, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 20, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 21, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 18, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 19, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 20, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 5, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 9, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 1, -10);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 2, -10);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 1, -1);
+}
+
+void test35()
+{
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 0, 0);
+}
+
+void test36()
+{
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 6, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 3, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 3, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+void test37()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+void test38()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 4, 6);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+}
+
+void test39()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 21, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 0, 20);
+}
+
+void test40()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 6, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 6, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 9, 11);
+}
+
+void test41()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+}
+
+void test42()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 5, 1);
+}
+
+void test43()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 2, 7);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 3, 6);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 8, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 2, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 3, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 1, 17);
+}
+
+void test44()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 8, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 3, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 8, 11);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 18, 1);
+}
+
+void test45()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 3, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 8, 11);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 2, -2);
+}
+
+void test46()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 10, 9);
+}
+
+void test47()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 1, 4);
+}
+
+void test48()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 9, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 5, 4);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 0, 10);
+}
+
+void test49()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 4, 5);
+}
+
+void test50()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+}
+
+void test51()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 6, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 3, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 5, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 3, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 4, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 1, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 2, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 11, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 8, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 10, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 1, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 2, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 21, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 18, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 19, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 20, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 6, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 3, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 5, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 3, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 4, 17);
+}
+
+void test52()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 1, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 2, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 11, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 8, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 10, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 1, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 2, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 21, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 18, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 19, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 20, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 1, -1);
+}
+
+void test53()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+}
+
+void test54()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 6, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 3, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 3, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    test13();
+    test14();
+    test15();
+    test16();
+    test17();
+    test18();
+    test19();
+    test20();
+    test21();
+    test22();
+    test23();
+    test24();
+    test25();
+    test26();
+    test27();
+    test28();
+    test29();
+    test30();
+    test31();
+    test32();
+    test33();
+    test34();
+    test35();
+    test36();
+    test37();
+    test38();
+    test39();
+    test40();
+    test41();
+    test42();
+    test43();
+    test44();
+    test45();
+    test46();
+    test47();
+    test48();
+    test49();
+    test50();
+    test51();
+    test52();
+    test53();
+    test54();
+}
diff --git a/test/strings/basic.string/string.ops/string::compare/string.pass.cpp b/test/strings/basic.string/string.ops/string::compare/string.pass.cpp
new file mode 100644
index 0000000..de7b106
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::compare/string.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const basic_string& str) const
+
+#include <string>
+#include <cassert>
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, const S& str, int x)
+{
+    assert(sign(s.compare(str)) == sign(x));
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), -5);
+    test(S(""), S("abcdefghij"), -10);
+    test(S(""), S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdefghij"), -5);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+    test(S("abcdefghij"), S(""), 10);
+    test(S("abcdefghij"), S("abcde"), 5);
+    test(S("abcdefghij"), S("abcdefghij"), 0);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghijklmnopqrst"), S(""), 20);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.not.of/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.not.of/char_size.pass.cpp
new file mode 100644
index 0000000..bc82706
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.not.of/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'q', 0, S::npos);
+    test(S(""), 'q', 1, S::npos);
+    test(S("kitcj"), 'q', 0, 0);
+    test(S("qkamf"), 'q', 1, 1);
+    test(S("nhmko"), 'q', 2, 2);
+    test(S("tpsaf"), 'q', 4, 4);
+    test(S("lahfb"), 'q', 5, S::npos);
+    test(S("irkhs"), 'q', 6, S::npos);
+    test(S("gmfhdaipsr"), 'q', 0, 0);
+    test(S("kantesmpgj"), 'q', 1, 1);
+    test(S("odaftiegpm"), 'q', 5, 5);
+    test(S("oknlrstdpi"), 'q', 9, 9);
+    test(S("eolhfgpjqk"), 'q', 10, S::npos);
+    test(S("pcdrofikas"), 'q', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+    test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+    test(S(""), 'q', S::npos);
+    test(S("csope"), 'q', 0);
+    test(S("gfsmthlkon"), 'q', 0);
+    test(S("laenfsbridchgotmkqpj"), 'q', 0);
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..3549ea3
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 3);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, 2);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, S::npos);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 0);
+    test(S("lahfb"), "irkhs", 0);
+    test(S("gmfhd"), "kantesmpgj", 2);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 0);
+    test(S("nbatdlmekr"), "bnrpe", 2);
+    test(S("jdmciepkaq"), "jtdaefblso", 2);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 0);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..edbe611
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, 1);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 1);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 3);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 3);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, S::npos);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 2);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 4);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.not.of/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.not.of/string_size.pass.cpp
new file mode 100644
index 0000000..4802073
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.not.of/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 3);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, 2);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 0);
+    test(S("lahfb"), S("irkhs"), 0);
+    test(S("gmfhd"), S("kantesmpgj"), 2);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 0);
+    test(S("nbatdlmekr"), S("bnrpe"), 2);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 2);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.of/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.of/char_size.pass.cpp
new file mode 100644
index 0000000..d178a03
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.of/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'e', 0, S::npos);
+    test(S(""), 'e', 1, S::npos);
+    test(S("kitcj"), 'e', 0, S::npos);
+    test(S("qkamf"), 'e', 1, S::npos);
+    test(S("nhmko"), 'e', 2, S::npos);
+    test(S("tpsaf"), 'e', 4, S::npos);
+    test(S("lahfb"), 'e', 5, S::npos);
+    test(S("irkhs"), 'e', 6, S::npos);
+    test(S("gmfhdaipsr"), 'e', 0, S::npos);
+    test(S("kantesmpgj"), 'e', 1, 4);
+    test(S("odaftiegpm"), 'e', 5, 6);
+    test(S("oknlrstdpi"), 'e', 9, S::npos);
+    test(S("eolhfgpjqk"), 'e', 10, S::npos);
+    test(S("pcdrofikas"), 'e', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+    test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+    test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+    test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+    test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+    test(S(""), 'e', S::npos);
+    test(S("csope"), 'e', 4);
+    test(S("gfsmthlkon"), 'e', S::npos);
+    test(S("laenfsbridchgotmkqpj"), 'e', 2);
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.of/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..6803024
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.of/pointer_size.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, 1);
+    test(S("clbao"), "ihqrfebgad", 0, 2);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, 4);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, S::npos);
+    test(S("pbsji"), "pcbahntsje", 4, S::npos);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, 3);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 0);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 0);
+    test(S("jdmciepkaq"), "jtdaefblso", 0);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.of/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..9423a1d
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.of/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, 1);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 1);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, 2);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 3);
+    test(S("gfcql"), "skbgtahqej", 1, 5, S::npos);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 4);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, 4);
+    test(S("hjeni"), "oapht", 2, 4, S::npos);
+    test(S("ocmfj"), "cifts", 2, 5, 3);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 3);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 8);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 8);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 1);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 3);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 1);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 4);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, 6);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 6);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.first.of/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.first.of/string_size.pass.cpp
new file mode 100644
index 0000000..84ba3cd
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.first.of/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, 1);
+    test(S("clbao"), S("ihqrfebgad"), 0, 2);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, 4);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, S::npos);
+    test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 0);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 0);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 0);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.not.of/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.not.of/char_size.pass.cpp
new file mode 100644
index 0000000..5c6275f
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.not.of/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'i', 0, S::npos);
+    test(S(""), 'i', 1, S::npos);
+    test(S("kitcj"), 'i', 0, 0);
+    test(S("qkamf"), 'i', 1, 1);
+    test(S("nhmko"), 'i', 2, 2);
+    test(S("tpsaf"), 'i', 4, 4);
+    test(S("lahfb"), 'i', 5, 4);
+    test(S("irkhs"), 'i', 6, 4);
+    test(S("gmfhdaipsr"), 'i', 0, 0);
+    test(S("kantesmpgj"), 'i', 1, 1);
+    test(S("odaftiegpm"), 'i', 5, 4);
+    test(S("oknlrstdpi"), 'i', 9, 8);
+    test(S("eolhfgpjqk"), 'i', 10, 9);
+    test(S("pcdrofikas"), 'i', 11, 9);
+    test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+    test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+    test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+    test(S(""), 'i', S::npos);
+    test(S("csope"), 'i', 4);
+    test(S("gfsmthlkon"), 'i', 9);
+    test(S("laenfsbridchgotmkqpj"), 'i', 19);
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..5ea8eec
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 0);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 1);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, 4);
+    test(S("omigs"), "kocgb", 5, 4);
+    test(S("onmje"), "fbslrjiqkm", 5, 4);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, 4);
+    test(S("igdsc"), "qngpd", 6, 4);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, S::npos);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, 8);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, 9);
+    test(S("mjqdgalkpc"), "dplqa", 10, 9);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, 9);
+    test(S("akiteljmoh"), "lofbc", 11, 9);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 4);
+    test(S("lahfb"), "irkhs", 4);
+    test(S("gmfhd"), "kantesmpgj", 4);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 9);
+    test(S("nbatdlmekr"), "bnrpe", 8);
+    test(S("jdmciepkaq"), "jtdaefblso", 9);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 19);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..0f3ca5c
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, S::npos);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, S::npos);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 1);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 1);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, 3);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 3);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 2);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, 4);
+    test(S("dajhn"), "psthd", 5, 0, 4);
+    test(S("jbgno"), "rpmjd", 5, 1, 4);
+    test(S("hkjae"), "dfsmk", 5, 2, 4);
+}
+
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 4);
+    test(S("ktdor"), "kipnf", 5, 5, 4);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, 4);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, 4);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 3);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 4);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 3);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, 4);
+    test(S("stedk"), "hrnat", 6, 0, 4);
+    test(S("tjkaf"), "gsqdt", 6, 1, 4);
+    test(S("dthpe"), "bspkd", 6, 2, 4);
+    test(S("klhde"), "ohcmb", 6, 4, 4);
+    test(S("bhlki"), "heatr", 6, 5, 4);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, 4);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, 4);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 4);
+    test(S("jblqp"), "njolbmspac", 6, 10, 3);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 0);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 0);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 8);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 8);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, 9);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, 9);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 9);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 9);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 9);
+    test(S("beanrfodgj"), "odpte", 10, 5, 9);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
+}
+
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, 9);
+    test(S("hobitmpsan"), "aocjb", 11, 0, 9);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 9);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 9);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 7);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
+}
+
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.not.of/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.not.of/string_size.pass.cpp
new file mode 100644
index 0000000..c5bb85d
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.not.of/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 0);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 1);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, 4);
+    test(S("omigs"), S("kocgb"), 5, 4);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 4);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, 4);
+    test(S("igdsc"), S("qngpd"), 6, 4);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, S::npos);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 8);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, 9);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 9);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, 9);
+    test(S("akiteljmoh"), S("lofbc"), 11, 9);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 4);
+    test(S("lahfb"), S("irkhs"), 4);
+    test(S("gmfhd"), S("kantesmpgj"), 4);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 9);
+    test(S("nbatdlmekr"), S("bnrpe"), 8);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 9);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 19);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.of/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.of/char_size.pass.cpp
new file mode 100644
index 0000000..c678bc6
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.of/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'm', 0, S::npos);
+    test(S(""), 'm', 1, S::npos);
+    test(S("kitcj"), 'm', 0, S::npos);
+    test(S("qkamf"), 'm', 1, S::npos);
+    test(S("nhmko"), 'm', 2, 2);
+    test(S("tpsaf"), 'm', 4, S::npos);
+    test(S("lahfb"), 'm', 5, S::npos);
+    test(S("irkhs"), 'm', 6, S::npos);
+    test(S("gmfhdaipsr"), 'm', 0, S::npos);
+    test(S("kantesmpgj"), 'm', 1, S::npos);
+    test(S("odaftiegpm"), 'm', 5, S::npos);
+    test(S("oknlrstdpi"), 'm', 9, S::npos);
+    test(S("eolhfgpjqk"), 'm', 10, S::npos);
+    test(S("pcdrofikas"), 'm', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+    test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+    test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+    test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+    test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+    test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+    test(S(""), 'm', S::npos);
+    test(S("csope"), 'm', S::npos);
+    test(S("gfsmthlkon"), 'm', 3);
+    test(S("laenfsbridchgotmkqpj"), 'm', 15);
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.of/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..36d00d2
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.of/pointer_size.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, S::npos);
+    test(S("clbao"), "ihqrfebgad", 0, S::npos);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, S::npos);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, 2);
+    test(S("pbsji"), "pcbahntsje", 4, 3);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, 3);
+    test(S("onmje"), "fbslrjiqkm", 5, 3);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, 2);
+    test(S("brqgo"), "rodhqklgmb", 6, 4);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, S::npos);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, 8);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 6);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, 8);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 9);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19);
+}
+
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 1);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 9);
+    test(S("jdmciepkaq"), "jtdaefblso", 8);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 19);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.of/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..73e854d
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.of/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, S::npos);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, S::npos);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 0);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 0);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, S::npos);
+    test(S("hjeni"), "oapht", 2, 4, 0);
+    test(S("ocmfj"), "cifts", 2, 5, 1);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 0);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 3);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 3);
+    test(S("ktdor"), "kipnf", 5, 5, 0);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 4);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 0);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 4);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, 2);
+    test(S("bhlki"), "heatr", 6, 5, 1);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 3);
+    test(S("jblqp"), "njolbmspac", 6, 10, 4);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos);
+    test(S("skrflobnqm"), "jqirk", 0, 2, S::npos);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, S::npos);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 2);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 4);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 6);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 8);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 1);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 2);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 7);
+    test(S("beanrfodgj"), "odpte", 10, 5, 7);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1);
+}
+
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 1);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 7);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 9);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::find.last.of/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::find.last.of/string_size.pass.cpp
new file mode 100644
index 0000000..414e564
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find.last.of/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, S::npos);
+    test(S("clbao"), S("ihqrfebgad"), 0, S::npos);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, S::npos);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, 2);
+    test(S("pbsji"), S("pcbahntsje"), 4, 3);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, 3);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 3);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, 2);
+    test(S("brqgo"), S("rodhqklgmb"), 6, 4);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 8);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, 8);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 1);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 9);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 8);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::find/char_size.pass.cpp
new file mode 100644
index 0000000..b60b157
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find(c) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + 1 <= s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'c', 0, S::npos);
+    test(S(""), 'c', 1, S::npos);
+    test(S("abcde"), 'c', 0, 2);
+    test(S("abcde"), 'c', 1, 2);
+    test(S("abcde"), 'c', 2, 2);
+    test(S("abcde"), 'c', 4, S::npos);
+    test(S("abcde"), 'c', 5, S::npos);
+    test(S("abcde"), 'c', 6, S::npos);
+    test(S("abcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcde"), 'c', 5, 7);
+    test(S("abcdeabcde"), 'c', 9, S::npos);
+    test(S("abcdeabcde"), 'c', 10, S::npos);
+    test(S("abcdeabcde"), 'c', 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+    test(S(""), 'c', S::npos);
+    test(S("abcde"), 'c', 2);
+    test(S("abcdeabcde"), 'c', 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+}
diff --git a/test/strings/basic.string/string.ops/string::find/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::find/pointer_size.pass.cpp
new file mode 100644
index 0000000..f05dd5d
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find/pointer_size.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(pos <= x && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(0 <= x && x + n <= s.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, S::npos);
+    test(S("abcde"), "abcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 0);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 0);
+    test(S("abcdeabcde"), "abcde", 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::find/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::find/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..3c39a92
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + n <= s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, S::npos);
+    test(S("abcde"), "abcde", 1, 2, S::npos);
+    test(S("abcde"), "abcde", 1, 4, S::npos);
+    test(S("abcde"), "abcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, S::npos);
+    test(S("abcde"), "abcde", 2, 2, S::npos);
+    test(S("abcde"), "abcde", 2, 4, S::npos);
+    test(S("abcde"), "abcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, S::npos);
+    test(S("abcde"), "abcde", 4, 2, S::npos);
+    test(S("abcde"), "abcde", 4, 4, S::npos);
+    test(S("abcde"), "abcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, S::npos);
+    test(S("abcde"), "abcde", 5, 2, S::npos);
+}
+
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, S::npos);
+    test(S("abcde"), "abcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 1, S::npos);
+    test(S("abcde"), "abcde", 6, 2, S::npos);
+    test(S("abcde"), "abcde", 6, 4, S::npos);
+    test(S("abcde"), "abcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos);
+}
+
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::find/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::find/string_size.pass.cpp
new file mode 100644
index 0000000..802d249
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::find/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, S::npos);
+    test(S("abcde"), S("abcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, S::npos);
+    test(S("abcdeabcde"), S("abcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 0);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 0);
+    test(S("abcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::rfind/char_size.pass.cpp b/test/strings/basic.string/string.ops/string::rfind/char_size.pass.cpp
new file mode 100644
index 0000000..a23c718
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::rfind/char_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.rfind(c) == x);
+    if (x != S::npos)
+        assert(x + 1 <= s.size());
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 'b', 0, S::npos);
+    test(S(""), 'b', 1, S::npos);
+    test(S("abcde"), 'b', 0, S::npos);
+    test(S("abcde"), 'b', 1, 1);
+    test(S("abcde"), 'b', 2, 1);
+    test(S("abcde"), 'b', 4, 1);
+    test(S("abcde"), 'b', 5, 1);
+    test(S("abcde"), 'b', 6, 1);
+    test(S("abcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcde"), 'b', 5, 1);
+    test(S("abcdeabcde"), 'b', 9, 6);
+    test(S("abcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcde"), 'b', 11, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+    test(S(""), 'b', S::npos);
+    test(S("abcde"), 'b', 1);
+    test(S("abcdeabcde"), 'b', 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+}
diff --git a/test/strings/basic.string/string.ops/string::rfind/pointer_size.pass.cpp b/test/strings/basic.string/string.ops/string::rfind/pointer_size.pass.cpp
new file mode 100644
index 0000000..2999d7f
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::rfind/pointer_size.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type pos = s.size();
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, 0);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, 0);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, 0);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, 5);
+    test(S("abcde"), "abcde", 6, 0);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, 10);
+    test(S("abcdeabcde"), "abcde", 11, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
+}
+
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 10);
+    test(S("abcdeabcde"), "abcde", 5);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::rfind/pointer_size_size.pass.cpp b/test/strings/basic.string/string.ops/string::rfind/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..7ed8b80
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::rfind/pointer_size_size.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+      typename S::size_type n, typename S::size_type x)
+{
+    assert(s.rfind(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + n <= s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, 0);
+    test(S(""), "abcde", 1, 0, 0);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, 0);
+    test(S("abcde"), "abcde", 1, 2, 0);
+    test(S("abcde"), "abcde", 1, 4, 0);
+    test(S("abcde"), "abcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, 0);
+    test(S("abcde"), "abcde", 2, 2, 0);
+    test(S("abcde"), "abcde", 2, 4, 0);
+    test(S("abcde"), "abcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, 0);
+    test(S("abcde"), "abcde", 4, 2, 0);
+    test(S("abcde"), "abcde", 4, 4, 0);
+    test(S("abcde"), "abcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, 0);
+    test(S("abcde"), "abcde", 5, 2, 0);
+}
+
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, 0);
+    test(S("abcde"), "abcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 1, 0);
+    test(S("abcde"), "abcde", 6, 2, 0);
+    test(S("abcde"), "abcde", 6, 4, 0);
+    test(S("abcde"), "abcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcde", 9, 2, 5);
+    test(S("abcdeabcde"), "abcde", 9, 4, 5);
+    test(S("abcdeabcde"), "abcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcde", 10, 2, 5);
+    test(S("abcdeabcde"), "abcde", 10, 4, 5);
+    test(S("abcdeabcde"), "abcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
+}
+
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcde", 11, 2, 5);
+    test(S("abcdeabcde"), "abcde", 11, 4, 5);
+    test(S("abcdeabcde"), "abcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+    test3();
+}
diff --git a/test/strings/basic.string/string.ops/string::rfind/string_size.pass.cpp b/test/strings/basic.string/string.ops/string::rfind/string_size.pass.cpp
new file mode 100644
index 0000000..0dc07a8
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::rfind/string_size.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+typedef std::string S;
+
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, 0);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, 0);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, 0);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, 0);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, 0);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, 5);
+    test(S("abcde"), S("abcde"), 6, 0);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, 10);
+    test(S("abcdeabcde"), S("abcde"), 11, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 10);
+    test(S("abcdeabcde"), S("abcde"), 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    test0();
+    test1();
+}
diff --git a/test/strings/basic.string/string.ops/string::substr/substr.pass.cpp b/test/strings/basic.string/string.ops/string::substr/substr.pass.cpp
new file mode 100644
index 0000000..4a2d483
--- /dev/null
+++ b/test/strings/basic.string/string.ops/string::substr/substr.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string substr(size_type pos = 0, size_type n = npos) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n)
+{
+    try
+    {
+        S str = s.substr(pos, n);
+        assert(str.__invariants());
+        assert(pos <= s.size());
+        typename S::size_type rlen = std::min(n, s.size() - pos);
+        assert(str.size() == rlen);
+        assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > s.size());
+    }
+}
+
+typedef std::string S;
+
+int main()
+{
+    test(S(""), 0, 0);
+    test(S(""), 1, 0);
+    test(S("pniot"), 0, 0);
+    test(S("htaob"), 0, 1);
+    test(S("fodgq"), 0, 2);
+    test(S("hpqia"), 0, 4);
+    test(S("qanej"), 0, 5);
+    test(S("dfkap"), 1, 0);
+    test(S("clbao"), 1, 1);
+    test(S("ihqrf"), 1, 2);
+    test(S("mekdn"), 1, 3);
+    test(S("ngtjf"), 1, 4);
+    test(S("srdfq"), 2, 0);
+    test(S("qkdrs"), 2, 1);
+    test(S("ikcrq"), 2, 2);
+    test(S("cdaih"), 2, 3);
+    test(S("dmajb"), 4, 0);
+    test(S("karth"), 4, 1);
+    test(S("lhcdo"), 5, 0);
+    test(S("acbsj"), 6, 0);
+    test(S("pbsjikaole"), 0, 0);
+    test(S("pcbahntsje"), 0, 1);
+    test(S("mprdjbeiak"), 0, 5);
+    test(S("fhepcrntko"), 0, 9);
+    test(S("eqmpaidtls"), 0, 10);
+    test(S("joidhalcmq"), 1, 0);
+    test(S("omigsphflj"), 1, 1);
+    test(S("kocgbphfji"), 1, 4);
+    test(S("onmjekafbi"), 1, 8);
+    test(S("fbslrjiqkm"), 1, 9);
+    test(S("oqmrjahnkg"), 5, 0);
+    test(S("jeidpcmalh"), 5, 1);
+    test(S("schfalibje"), 5, 2);
+    test(S("crliponbqe"), 5, 4);
+    test(S("igdscopqtm"), 5, 5);
+    test(S("qngpdkimlc"), 9, 0);
+    test(S("thdjgafrlb"), 9, 1);
+    test(S("hcjitbfapl"), 10, 0);
+    test(S("mgojkldsqh"), 11, 0);
+    test(S("gfshlcmdjreqipbontak"), 0, 0);
+    test(S("nadkhpfemgclosibtjrq"), 0, 1);
+    test(S("nkodajteqplrbifhmcgs"), 0, 10);
+    test(S("ofdrqmkeblthacpgijsn"), 0, 19);
+    test(S("gbmetiprqdoasckjfhln"), 0, 20);
+    test(S("bdfjqgatlksriohemnpc"), 1, 0);
+    test(S("crnklpmegdqfiashtojb"), 1, 1);
+    test(S("ejqcnahdrkfsmptilgbo"), 1, 9);
+    test(S("jsbtafedocnirgpmkhql"), 1, 18);
+    test(S("prqgnlbaejsmkhdctoif"), 1, 19);
+    test(S("qnmodrtkebhpasifgcjl"), 10, 0);
+    test(S("pejafmnokrqhtisbcdgl"), 10, 1);
+    test(S("cpebqsfmnjdolhkratgi"), 10, 5);
+    test(S("odnqkgijrhabfmcestlp"), 10, 9);
+    test(S("lmofqdhpkibagnrcjste"), 10, 10);
+    test(S("lgjqketopbfahrmnsicd"), 19, 0);
+    test(S("ktsrmnqagdecfhijpobl"), 19, 1);
+    test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
+    test(S("dplqartnfgejichmoskb"), 21, 0);
+}
diff --git a/test/strings/basic.string/string.require/nothing_to_do.pass.cpp b/test/strings/basic.string/string.require/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/basic.string/string.require/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/basic.string/test_allocator.h b/test/strings/basic.string/test_allocator.h
new file mode 100644
index 0000000..a949a25
--- /dev/null
+++ b/test/strings/basic.string/test_allocator.h
@@ -0,0 +1,70 @@
+#ifndef TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+class test_alloc_base
+{
+protected:
+    static int count;
+public:
+    static int throw_after;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(-1) {}
+    explicit test_allocator(int i) throw() : data_(i) {}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {}
+    ~test_allocator() throw() {data_ = 0;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            if (count >= throw_after)
+                throw std::bad_alloc();
+            ++count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+#endif
diff --git a/test/strings/basic.string/test_traits.h b/test/strings/basic.string/test_traits.h
new file mode 100644
index 0000000..885d50b
--- /dev/null
+++ b/test/strings/basic.string/test_traits.h
@@ -0,0 +1,10 @@
+#ifndef TEST_TRAITS_H
+#define TEST_TRAITS_H
+
+template <class charT>
+struct test_traits
+{
+    typedef charT     char_type;
+};
+
+#endif
diff --git a/test/strings/basic.string/types.pass.cpp b/test/strings/basic.string/types.pass.cpp
new file mode 100644
index 0000000..5f337ab
--- /dev/null
+++ b/test/strings/basic.string/types.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test nested types and default template args:
+
+// template<class charT, class traits = char_traits<charT>, 
+//   class Allocator = allocator<charT> >
+// {
+// public:
+//     // types: 
+//     typedef traits traits_type; 
+//     typedef typename traits::char_type value_type; 
+//     typedef Allocator allocator_type; 
+//     typedef typename Allocator::size_type size_type; 
+//     typedef typename Allocator::difference_type difference_type; 
+//     typedef typename Allocator::reference reference; 
+//     typedef typename Allocator::const_reference const_reference; 
+//     typedef typename Allocator::pointer pointer; 
+//     typedef typename Allocator::const_pointer const_pointer; 
+//     typedef implementation-defined iterator; // See 23.1 
+//     typedef implementation-defined const_iterator; // See 23.1 
+//     typedef std::reverse_iterator<iterator> reverse_iterator; 
+//     typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 
+//     static const size_type npos = -1; 
+// };
+
+#include <string>
+#include <iterator>
+#include <type_traits>
+
+#include "test_traits.h"
+#include "test_allocator.h"
+
+template <class Traits, class Allocator>
+void
+test()
+{
+    typedef std::basic_string<typename Traits::char_type, Traits, Allocator> S;
+
+    static_assert((std::is_same<typename S::traits_type, Traits>::value), "");
+    static_assert((std::is_same<typename S::value_type, typename Traits::char_type>::value), "");
+    static_assert((std::is_same<typename S::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename S::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename S::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename S::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<typename S::reference, typename Allocator::reference>::value), "");
+    static_assert((std::is_same<typename S::const_reference, typename Allocator::const_reference>::value), "");
+    static_assert((std::is_same<typename S::pointer, typename Allocator::pointer>::value), "");
+    static_assert((std::is_same<typename S::const_pointer, typename Allocator::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename S::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename S::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename S::reverse_iterator,
+        std::reverse_iterator<typename S::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename S::const_reverse_iterator,
+        std::reverse_iterator<typename S::const_iterator> >::value), "");
+    static_assert(S::npos == -1, "");
+}
+
+int main()
+{
+    test<test_traits<char>, test_allocator<char> >();
+    test<std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+    static_assert((std::is_same<std::basic_string<char>::traits_type,
+                                std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_string<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+}
diff --git a/test/strings/c.strings/cctype.pass.cpp b/test/strings/c.strings/cctype.pass.cpp
new file mode 100644
index 0000000..69b3ed0
--- /dev/null
+++ b/test/strings/c.strings/cctype.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+    static_assert((std::is_same<decltype(std::isalnum(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isalpha(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isblank(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iscntrl(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isgraph(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::islower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isprint(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ispunct(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isspace(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isupper(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isxdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::tolower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::toupper(0)), int>::value), "");
+
+    assert(isalnum('a'));
+    assert(isalpha('a'));
+    assert(isblank(' '));
+    assert(!iscntrl(' '));
+    assert(!isdigit('a'));
+    assert(isgraph('a'));
+    assert(islower('a'));
+    assert(isprint('a'));
+    assert(!ispunct('a'));
+    assert(!isspace('a'));
+    assert(!isupper('a'));
+    assert(isxdigit('a'));
+    assert(tolower('A') == 'a');
+    assert(toupper('a') == 'A');
+}
diff --git a/test/strings/c.strings/cstring.pass.cpp b/test/strings/c.strings/cstring.pass.cpp
new file mode 100644
index 0000000..dbb611f
--- /dev/null
+++ b/test/strings/c.strings/cstring.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    std::size_t s = 0;
+    void* vp = 0;
+    const void* vpc = 0;
+    char* cp = 0;
+    const char* cpc = 0;
+    static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), "");
+    static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), "");
+}
diff --git a/test/strings/c.strings/cuchar.pass.cpp b/test/strings/c.strings/cuchar.pass.cpp
new file mode 100644
index 0000000..ec5f6a0
--- /dev/null
+++ b/test/strings/c.strings/cuchar.pass.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cuchar>
+
+#include <cuchar>
+
+int main()
+{
+}
diff --git a/test/strings/c.strings/cwchar.pass.cpp b/test/strings/c.strings/cwchar.pass.cpp
new file mode 100644
index 0000000..92a70c5
--- /dev/null
+++ b/test/strings/c.strings/cwchar.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+    std::mbstate_t mb = {0};
+    std::size_t s = 0;
+    std::tm tm = {0};
+    std::wint_t w = 0;
+    ::FILE* fp = 0;
+    __darwin_va_list va;
+    char* ns = 0;
+    wchar_t* ws = 0;
+    static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fwscanf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::swprintf(ws, s, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::swscanf(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfwprintf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::wcstold(L"", (wchar_t**)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(std::wcscpy(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscat(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncat(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscmp(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcscoll(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcsxfrm(ws, L"", s)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscspn(L"", L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcslen(L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsspn(L"", L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemcmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemmove(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemset(ws, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsftime(ws, s, L"", &tm)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::btowc(0)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wctob(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbsinit(&mb)), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbrlen("", s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::mbrtowc(ws, "", s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), "");
+}
diff --git a/test/strings/c.strings/cwctype.pass.cpp b/test/strings/c.strings/cwctype.pass.cpp
new file mode 100644
index 0000000..64934bd
--- /dev/null
+++ b/test/strings/c.strings/cwctype.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+    std::wint_t w = 0;
+    std::wctrans_t wctr = 0;
+    std::wctype_t wct = 0;
+    static_assert((std::is_same<decltype(std::iswalnum(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswalpha(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswblank(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswcntrl(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswgraph(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswlower(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswprint(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswpunct(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswspace(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswupper(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswxdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswctype(w, wct)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wctype("")), std::wctype_t>::value), "");
+    static_assert((std::is_same<decltype(std::towlower(w)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::towupper(w)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::towctrans(w, wctr)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wctrans("")), std::wctrans_t>::value), "");
+}
diff --git a/test/strings/c.strings/version_cctype.pass.cpp b/test/strings/c.strings/version_cctype.pass.cpp
new file mode 100644
index 0000000..5c2e817
--- /dev/null
+++ b/test/strings/c.strings/version_cctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/strings/c.strings/version_cstring.pass.cpp b/test/strings/c.strings/version_cstring.pass.cpp
new file mode 100644
index 0000000..670e0e1
--- /dev/null
+++ b/test/strings/c.strings/version_cstring.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/strings/c.strings/version_cuchar.pass.cpp b/test/strings/c.strings/version_cuchar.pass.cpp
new file mode 100644
index 0000000..11bbeb6
--- /dev/null
+++ b/test/strings/c.strings/version_cuchar.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cuchar>
+
+#include <cuchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/strings/c.strings/version_cwchar.pass.cpp b/test/strings/c.strings/version_cwchar.pass.cpp
new file mode 100644
index 0000000..612762b
--- /dev/null
+++ b/test/strings/c.strings/version_cwchar.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/strings/c.strings/version_cwctype.pass.cpp b/test/strings/c.strings/version_cwctype.pass.cpp
new file mode 100644
index 0000000..bc3c090
--- /dev/null
+++ b/test/strings/c.strings/version_cwctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
new file mode 100644
index 0000000..92b1ea4
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    std::char_traits<char>::assign(c, 'a');
+    assert(c == 'a');
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
new file mode 100644
index 0000000..5a44ea3
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    char s2[3] = {0};
+    assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2);
+    assert(s2[0] == char(5));
+    assert(s2[1] == char(5));
+    assert(s2[2] == char(5));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
new file mode 100644
index 0000000..6f51db7
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::compare("", "", 0) == 0);
+
+    assert(std::char_traits<char>::compare("1", "1", 1) == 0);
+    assert(std::char_traits<char>::compare("1", "2", 1) < 0);
+    assert(std::char_traits<char>::compare("2", "1", 1) > 0);
+
+    assert(std::char_traits<char>::compare("12", "12", 2) == 0);
+    assert(std::char_traits<char>::compare("12", "13", 2) < 0);
+    assert(std::char_traits<char>::compare("12", "22", 2) < 0);
+    assert(std::char_traits<char>::compare("13", "12", 2) > 0);
+    assert(std::char_traits<char>::compare("22", "12", 2) > 0);
+
+    assert(std::char_traits<char>::compare("123", "123", 3) == 0);
+    assert(std::char_traits<char>::compare("123", "223", 3) < 0);
+    assert(std::char_traits<char>::compare("123", "133", 3) < 0);
+    assert(std::char_traits<char>::compare("123", "124", 3) < 0);
+    assert(std::char_traits<char>::compare("223", "123", 3) > 0);
+    assert(std::char_traits<char>::compare("133", "123", 3) > 0);
+    assert(std::char_traits<char>::compare("124", "123", 3) > 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
new file mode 100644
index 0000000..45cfc50
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    char s2[3] = {0};
+    assert(std::char_traits<char>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char(1));
+    assert(s2[1] == char(2));
+    assert(s2[2] == char(3));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
new file mode 100644
index 0000000..041b4d0
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::eof() == EOF);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
new file mode 100644
index 0000000..f2ddbfa
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    assert(std::char_traits<char>::eq('a', 'a'));
+    assert(!std::char_traits<char>::eq('a', 'A'));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp
new file mode 100644
index 0000000..446a83f
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.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>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert( std::char_traits<char>::eq_int_type('a', 'a'));
+    assert(!std::char_traits<char>::eq_int_type('a', 'A'));
+    assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A'));
+    assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(),
+                                                std::char_traits<char>::eof()));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
new file mode 100644
index 0000000..2e0f2ff
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    assert(std::char_traits<char>::find(s1, 3, char(1)) == s1);
+    assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1);
+    assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2);
+    assert(std::char_traits<char>::find(s1, 3, char(4)) == 0);
+    assert(std::char_traits<char>::find(s1, 3, char(0)) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
new file mode 100644
index 0000000..b111ba4
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.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>
+
+// template<> struct char_traits<char>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::length("") == 0);
+    assert(std::char_traits<char>::length("a") == 1);
+    assert(std::char_traits<char>::length("aa") == 2);
+    assert(std::char_traits<char>::length("aaa") == 3);
+    assert(std::char_traits<char>::length("aaaa") == 4);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
new file mode 100644
index 0000000..6479c66
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    assert(!std::char_traits<char>::lt('a', 'a'));
+    assert( std::char_traits<char>::lt('A', 'a'));
+    assert(!std::char_traits<char>::lt('A' + 127, 'a'));
+    assert(!std::char_traits<char>::lt('A' - 127, 'a'));
+    assert( std::char_traits<char>::lt('A', 'a' + 127));
+    assert( std::char_traits<char>::lt('A', 'a' - 127));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
new file mode 100644
index 0000000..3627550
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    assert(std::char_traits<char>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char(2));
+    assert(s1[1] == char(3));
+    assert(s1[2] == char(3));
+    s1[2] = char(0);
+    assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char(2));
+    assert(s1[1] == char(2));
+    assert(s1[2] == char(3));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp
new file mode 100644
index 0000000..44d26be
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.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>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::not_eof('a') == 'a');
+    assert(std::char_traits<char>::not_eof('A') == 'A');
+    assert(std::char_traits<char>::not_eof(0) == 0);
+    assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) !=
+           std::char_traits<char>::eof());
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
new file mode 100644
index 0000000..8b5d1b1
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::to_char_type('a') == 'a');
+    assert(std::char_traits<char>::to_char_type('A') == 'A');
+    assert(std::char_traits<char>::to_char_type(0) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
new file mode 100644
index 0000000..2cb41de
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::to_int_type('a') == 'a');
+    assert(std::char_traits<char>::to_int_type('A') == 'A');
+    assert(std::char_traits<char>::to_int_type(0) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
new file mode 100644
index 0000000..dd0afbf
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// typedef char      char_type; 
+// typedef int       int_type; 
+// typedef streamoff off_type; 
+// typedef streampos pos_type; 
+// typedef mbstate_t state_type; 
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
new file mode 100644
index 0000000..6002d0b
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.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>
+
+// template<> struct char_traits<char16_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t c = u'\0';
+    std::char_traits<char16_t>::assign(c, u'a');
+    assert(c == u'a');
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
new file mode 100644
index 0000000..c5a98a5
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    char16_t s2[3] = {0};
+    assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2);
+    assert(s2[0] == char16_t(5));
+    assert(s2[1] == char16_t(5));
+    assert(s2[2] == char16_t(5));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
new file mode 100644
index 0000000..55e82d5
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
+
+    assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
+    assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
+    assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
+
+    assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
+    assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
+    assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
+    assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
+    assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
+
+    assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
+    assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
+    assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
new file mode 100644
index 0000000..7edf6e6
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    char16_t s2[3] = {0};
+    assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char16_t(1));
+    assert(s2[1] == char16_t(2));
+    assert(s2[2] == char16_t(3));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
new file mode 100644
index 0000000..dad0ba9
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof();
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
new file mode 100644
index 0000000..1a8be4e
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.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>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t c = u'\0';
+    assert(std::char_traits<char16_t>::eq(u'a', u'a'));
+    assert(!std::char_traits<char16_t>::eq(u'a', u'A'));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..13befce
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a'));
+    assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A'));
+    assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A'));
+    assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(),
+                                                    std::char_traits<char16_t>::eof()));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
new file mode 100644
index 0000000..765da3e
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
new file mode 100644
index 0000000..4810980
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char16_t>::length(u"") == 0);
+    assert(std::char_traits<char16_t>::length(u"a") == 1);
+    assert(std::char_traits<char16_t>::length(u"aa") == 2);
+    assert(std::char_traits<char16_t>::length(u"aaa") == 3);
+    assert(std::char_traits<char16_t>::length(u"aaaa") == 4);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
new file mode 100644
index 0000000..a322196
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.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>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t c = u'\0';
+    assert(!std::char_traits<char16_t>::lt(u'a', u'a'));
+    assert( std::char_traits<char16_t>::lt(u'A', u'a'));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
new file mode 100644
index 0000000..7c172e6
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char16_t(2));
+    assert(s1[1] == char16_t(3));
+    assert(s1[2] == char16_t(3));
+    s1[2] = char16_t(0);
+    assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char16_t(2));
+    assert(s1[1] == char16_t(2));
+    assert(s1[2] == char16_t(3));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
new file mode 100644
index 0000000..3de319c
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char16_t>::not_eof(u'a') == u'a');
+    assert(std::char_traits<char16_t>::not_eof(u'A') == u'A');
+    assert(std::char_traits<char16_t>::not_eof(0) == 0);
+    assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) !=
+           std::char_traits<char16_t>::eof());
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp
new file mode 100644
index 0000000..e60ef91
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.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>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a');
+    assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A');
+    assert(std::char_traits<char16_t>::to_char_type(0) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp
new file mode 100644
index 0000000..6d07b79
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.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>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a');
+    assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A');
+    assert(std::char_traits<char16_t>::to_int_type(0) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
new file mode 100644
index 0000000..95ce8ec
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// typedef char16_t       char_type; 
+// typedef uint_least16_t int_type; 
+// typedef streamoff      off_type; 
+// typedef u16streampos   pos_type; 
+// typedef mbstate_t      state_type; 
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), "");
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
new file mode 100644
index 0000000..0caf5fd
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.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>
+
+// template<> struct char_traits<char32_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t c = U'\0';
+    std::char_traits<char32_t>::assign(c, U'a');
+    assert(c == U'a');
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
new file mode 100644
index 0000000..e3702d4
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    char32_t s2[3] = {0};
+    assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2);
+    assert(s2[0] == char32_t(5));
+    assert(s2[1] == char32_t(5));
+    assert(s2[2] == char32_t(5));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
new file mode 100644
index 0000000..0f0999b
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0);
+
+    assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0);
+    assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0);
+    assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0);
+
+    assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0);
+    assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0);
+    assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0);
+    assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0);
+    assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0);
+
+    assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0);
+    assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0);
+    assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
new file mode 100644
index 0000000..8e5aa66
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    char32_t s2[3] = {0};
+    assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char32_t(1));
+    assert(s2[1] == char32_t(2));
+    assert(s2[2] == char32_t(3));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
new file mode 100644
index 0000000..f783867
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof();
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
new file mode 100644
index 0000000..fddd200
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.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>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t c = U'\0';
+    assert(std::char_traits<char32_t>::eq(U'a', U'a'));
+    assert(!std::char_traits<char32_t>::eq(U'a', U'A'));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..d52172c
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a'));
+    assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A'));
+    assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A'));
+    assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(),
+                                                    std::char_traits<char32_t>::eof()));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
new file mode 100644
index 0000000..4352ecf
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
new file mode 100644
index 0000000..2c35e50
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char32_t>::length(U"") == 0);
+    assert(std::char_traits<char32_t>::length(U"a") == 1);
+    assert(std::char_traits<char32_t>::length(U"aa") == 2);
+    assert(std::char_traits<char32_t>::length(U"aaa") == 3);
+    assert(std::char_traits<char32_t>::length(U"aaaa") == 4);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
new file mode 100644
index 0000000..2b7e3cd
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.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>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t c = U'\0';
+    assert(!std::char_traits<char32_t>::lt(U'a', U'a'));
+    assert( std::char_traits<char32_t>::lt(U'A', U'a'));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
new file mode 100644
index 0000000..dc0bb78
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char32_t(2));
+    assert(s1[1] == char32_t(3));
+    assert(s1[2] == char32_t(3));
+    s1[2] = char32_t(0);
+    assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char32_t(2));
+    assert(s1[1] == char32_t(2));
+    assert(s1[2] == char32_t(3));
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
new file mode 100644
index 0000000..1722282
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char32_t>::not_eof(U'a') == U'a');
+    assert(std::char_traits<char32_t>::not_eof(U'A') == U'A');
+    assert(std::char_traits<char32_t>::not_eof(0) == 0);
+    assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) !=
+           std::char_traits<char32_t>::eof());
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp
new file mode 100644
index 0000000..fd1825a
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.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>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a');
+    assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A');
+    assert(std::char_traits<char32_t>::to_char_type(0) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp
new file mode 100644
index 0000000..7d5dbe4
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.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>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a');
+    assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A');
+    assert(std::char_traits<char32_t>::to_int_type(0) == 0);
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
new file mode 100644
index 0000000..db1d393
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// typedef char32_t       char_type; 
+// typedef uint_least32_t int_type; 
+// typedef streamoff      off_type; 
+// typedef u32streampos   pos_type; 
+// typedef mbstate_t      state_type; 
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), "");
+#endif
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
new file mode 100644
index 0000000..650b8ba
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    std::char_traits<wchar_t>::assign(c, L'a');
+    assert(c == L'a');
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
new file mode 100644
index 0000000..a28da61
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    wchar_t s2[3] = {0};
+    assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2);
+    assert(s2[0] == wchar_t(5));
+    assert(s2[1] == wchar_t(5));
+    assert(s2[2] == wchar_t(5));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
new file mode 100644
index 0000000..d8cac4f
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
new file mode 100644
index 0000000..abecfc1
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    wchar_t s2[3] = {0};
+    assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == wchar_t(1));
+    assert(s2[1] == wchar_t(2));
+    assert(s2[2] == wchar_t(3));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
new file mode 100644
index 0000000..77637e0
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::eof() == WEOF);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
new file mode 100644
index 0000000..53ff74e
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    assert(std::char_traits<wchar_t>::eq(L'a', L'a'));
+    assert(!std::char_traits<wchar_t>::eq(L'a', L'A'));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..3cb1df9
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.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>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a'));
+    assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A'));
+    assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A'));
+    assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(),
+                                                   std::char_traits<wchar_t>::eof()));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
new file mode 100644
index 0000000..6a416e8
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
new file mode 100644
index 0000000..8d437ce
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.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>
+
+// template<> struct char_traits<wchar_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::length(L"") == 0);
+    assert(std::char_traits<wchar_t>::length(L"a") == 1);
+    assert(std::char_traits<wchar_t>::length(L"aa") == 2);
+    assert(std::char_traits<wchar_t>::length(L"aaa") == 3);
+    assert(std::char_traits<wchar_t>::length(L"aaaa") == 4);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
new file mode 100644
index 0000000..b4978e1
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    assert(!std::char_traits<wchar_t>::lt(L'a', L'a'));
+    assert( std::char_traits<wchar_t>::lt(L'A', L'a'));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
new file mode 100644
index 0000000..3227e7e
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == wchar_t(2));
+    assert(s1[1] == wchar_t(3));
+    assert(s1[2] == wchar_t(3));
+    s1[2] = wchar_t(0);
+    assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == wchar_t(2));
+    assert(s1[1] == wchar_t(2));
+    assert(s1[2] == wchar_t(3));
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
new file mode 100644
index 0000000..f68b05c
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.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>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::not_eof(0) == 0);
+    assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) !=
+           std::char_traits<wchar_t>::eof());
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
new file mode 100644
index 0000000..40d941a
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::to_char_type(0) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
new file mode 100644
index 0000000..e993cd9
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::to_int_type(0) == 0);
+}
diff --git a/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
new file mode 100644
index 0000000..2353cb1
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// typedef wchar_t   char_type; 
+// typedef int       int_type; 
+// typedef streamoff off_type; 
+// typedef streampos pos_type; 
+// typedef mbstate_t state_type; 
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/char.traits/nothing_to_do.pass.cpp b/test/strings/char.traits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/strings/char.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/strings/string.classes/typedefs.pass.cpp b/test/strings/string.classes/typedefs.pass.cpp
new file mode 100644
index 0000000..f4b0cb0
--- /dev/null
+++ b/test/strings/string.classes/typedefs.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test for the existence of:
+
+// basic_string typedef names 
+// typedef basic_string<char> string; 
+// typedef basic_string<char16_t> u16string; 
+// typedef basic_string<char32_t> u32string; 
+// typedef basic_string<wchar_t> wstring;
+
+#include <string>
+
+int main()
+{
+    typedef std::string test1;
+    typedef std::wstring test2;
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::u16string test3;
+    typedef std::u32string test4;
+#endif
+}
diff --git a/test/strings/version.pass.cpp b/test/strings/version.pass.cpp
new file mode 100644
index 0000000..9756277
--- /dev/null
+++ b/test/strings/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+#include <string>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/testit b/test/testit
new file mode 100755
index 0000000..b06e8e5
--- /dev/null
+++ b/test/testit
@@ -0,0 +1,175 @@
+#!/bin/bash
+# //===--------------------------- testit ---------------------------------===//
+# //
+# // ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+# //
+# // This file is distributed under the University of Illinois Open Source
+# // License. See LICENSE.TXT for details.
+# //
+# //===--------------------------------------------------------------------===//
+
+BACKUP="../"
+
+currentpath=`pwd`
+origpath=$currentpath
+currentdir=`basename $currentpath`
+while [ $currentdir != "test" ]; do
+	if [ $currentdir == "/" ]
+	then
+		echo "current directory must be in or under \"test\"."
+		exit 1
+	fi
+	cd ..
+	currentpath=`pwd`
+	currentdir=`basename $currentpath`
+	BACKUP="../"$BACKUP
+done
+cd $origpath
+
+if [ -z $CC ]
+then
+	CC=g++
+fi
+
+auto_header=0
+
+if [ -z $HEADER_INCLUDE ]
+then
+	HEADER_INCLUDE=$BACKUP"include"
+	let "auto_header+=1"
+fi
+
+auto_lib=0
+
+SOURCE_LIB=/usr/lib/libc++.dylib
+#SOURCE_LIB=/Users/hinnant/Development/libcpp/lib/libc++.a
+
+if [ -z $SOURCE_LIB ]
+then
+	SOURCE_LIB=$BACKUP"lib/libc++.dylib"
+	let "auto_lib+=1"
+fi
+
+if [ -z "$OPTIONS" ]
+then
+ 	OPTIONS="-nostdinc++ -nodefaultlibs /usr/lib/libSystem.B.dylib -arch `arch`"
+fi
+
+FAIL=0
+PASS=0
+UNIMPLEMENTED=0
+IMPLEMENTED_FAIL=0
+IMPLEMENTED_PASS=0
+
+function afunc
+{
+	fail=0
+	pass=0
+	if (ls *.fail.cpp &> /dev/null)
+	then
+		for FILE in $(ls *.fail.cpp); do
+			if $CC $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB $FILE &> /dev/null
+			then
+				rm ./a.out
+				echo "$FILE should not compile"
+				let "fail+=1"
+			else
+				let "pass+=1"
+			fi
+		done
+	fi
+	
+	if (ls *.pass.cpp &> /dev/null)
+	then
+		for FILE in $(ls *.pass.cpp); do
+			if $CC $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB $FILE
+			then
+				if ./a.out
+				then
+					rm ./a.out
+					let "pass+=1"
+				else
+					echo "$FILE failed at run time"
+					let "fail+=1"
+					rm ./a.out
+				fi
+			else
+				echo "$FILE failed to compile"
+				let "fail+=1"
+			fi
+		done
+	fi
+
+	if [ $fail -gt 0 ]
+	then
+		echo "failed $fail tests in `pwd`"
+		let "IMPLEMENTED_FAIL+=1"
+	fi
+	if [ $pass -gt 0 ]
+	then
+		echo "passed $pass tests in `pwd`"
+		if [ $fail -eq 0 ]
+		then
+			let "IMPLEMENTED_PASS+=1"
+		fi
+	fi
+	if [ $fail -eq 0 -a $pass -eq 0 ]
+	then
+		echo "not implemented:  `pwd`"
+		let "UNIMPLEMENTED+=1"
+	fi
+
+	let "FAIL+=$fail"
+	let "PASS+=$pass"
+
+	for FILE in *
+	do
+		if [ -d "$FILE" ];
+		then
+			cd $FILE
+			if [ $auto_header -eq 1 ]
+			then
+				SAVE_HEADER_INCLUDE=$HEADER_INCLUDE
+				HEADER_INCLUDE="../"$HEADER_INCLUDE
+			fi
+			if [ $auto_lib -eq 1 ]
+			then
+				SAVE_SOURCE_LIB=$SOURCE_LIB
+				SOURCE_LIB="../"$SOURCE_LIB
+			fi
+
+			afunc
+
+			if [ $auto_header -eq 1 ]
+			then
+				HEADER_INCLUDE=${HEADER_INCLUDE:3}
+			fi
+			if [ $auto_lib -eq 1 ]
+			then
+				SOURCE_LIB=${SOURCE_LIB:3}
+			fi
+			cd ..
+		fi
+	done
+}
+
+afunc
+
+echo "****************************************************"
+echo "Results for `pwd`:"
+echo "using `$CC --version`"
+echo "with $OPTIONS -I$HEADER_INCLUDE $SOURCE_LIB"
+echo "----------------------------------------------------"
+echo "sections without tests   : $UNIMPLEMENTED"
+echo "sections with failures   : $IMPLEMENTED_FAIL"
+echo "sections without failures: $IMPLEMENTED_PASS"
+echo "                       +   ----"
+echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
+echo "----------------------------------------------------"
+echo "number of tests failed   : $FAIL"
+echo "number of tests passed   : $PASS"
+echo "                       +   ----"
+echo "total number of tests    : $(($FAIL+$PASS))"
+echo "****************************************************"
+
+exit $FAIL
diff --git a/test/thread/futures/futures.overview/future_errc.pass.cpp b/test/thread/futures/futures.overview/future_errc.pass.cpp
new file mode 100644
index 0000000..45ee779
--- /dev/null
+++ b/test/thread/futures/futures.overview/future_errc.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class future_errc
+// {
+//     broken_promise,
+//     future_already_retrieved,
+//     promise_already_satisfied,
+//     no_state
+// };
+
+#include <future>
+
+int main()
+{
+    static_assert(std::future_errc::broken_promise == 0, "");
+    static_assert(std::future_errc::future_already_retrieved == 1, "");
+    static_assert(std::future_errc::promise_already_satisfied == 2, "");
+    static_assert(std::future_errc::no_state == 3, "");
+}
diff --git a/test/thread/futures/futures.overview/future_status.pass.cpp b/test/thread/futures/futures.overview/future_status.pass.cpp
new file mode 100644
index 0000000..e783ca7
--- /dev/null
+++ b/test/thread/futures/futures.overview/future_status.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class future_status
+// {
+//     ready,
+//     timeout,
+//     deferred
+// };
+
+#include <future>
+
+int main()
+{
+    static_assert(std::future_status::ready == 0, "");
+    static_assert(std::future_status::timeout == 1, "");
+    static_assert(std::future_status::deferred == 2, "");
+}
diff --git a/test/thread/futures/futures.overview/launch.pass.cpp b/test/thread/futures/futures.overview/launch.pass.cpp
new file mode 100644
index 0000000..1c308e4
--- /dev/null
+++ b/test/thread/futures/futures.overview/launch.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class launch
+// {
+//     any,
+//     async,
+//     sync
+// };
+
+#include <future>
+
+int main()
+{
+    static_assert(std::launch::any == 0, "");
+    static_assert(std::launch::async == 1, "");
+    static_assert(std::launch::sync == 2, "");
+}
diff --git a/test/thread/futures/version.pass.cpp b/test/thread/futures/version.pass.cpp
new file mode 100644
index 0000000..2cfe55d
--- /dev/null
+++ b/test/thread/futures/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+#include <future>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/thread/macro.pass.cpp b/test/thread/macro.pass.cpp
new file mode 100644
index 0000000..baa2e5c
--- /dev/null
+++ b/test/thread/macro.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// #define __STDCPP_THREADS __cplusplus
+
+#include <thread>
+
+int main()
+{
+#ifndef __STDCPP_THREADS
+#error __STDCPP_THREADS is not defined
+#endif
+}
diff --git a/test/thread/thread.condition/cv_status.pass.cpp b/test/thread/thread.condition/cv_status.pass.cpp
new file mode 100644
index 0000000..be2e9a3
--- /dev/null
+++ b/test/thread/thread.condition/cv_status.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// enum class cv_status { no_timeout, timeout };
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    assert(std::cv_status::no_timeout == 0);
+    assert(std::cv_status::timeout == 1);
+}
diff --git a/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp b/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..4fcb369
--- /dev/null
+++ b/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// void
+//   notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+#error notify_all_at_thread_exit not implemented
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp b/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
new file mode 100644
index 0000000..4d8d6d6
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable& operator=(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv0;
+    std::condition_variable cv1;
+    cv1 = cv0;
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp b/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
new file mode 100644
index 0000000..c302d6a
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv0;
+    std::condition_variable cv1(cv0);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp
new file mode 100644
index 0000000..71cb830
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv;
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp
new file mode 100644
index 0000000..72382ad
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/destructor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// ~condition_variable();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable* cv;
+std::mutex m;
+typedef std::unique_lock<std::mutex> Lock;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+    Lock lk(m);
+    f_ready = true;
+    cv->notify_one();
+    delete cv;
+}
+
+void g()
+{
+    Lock lk(m);
+    g_ready = true;
+    cv->notify_one();
+    while (!f_ready)
+        cv->wait(lk);
+}
+
+int main()
+{
+    cv = new std::condition_variable;
+    std::thread th2(g);
+    Lock lk(m);
+    while (!g_ready)
+        cv->wait(lk);
+    lk.unlock();
+    std::thread th1(f);
+    th1.join();
+    th2.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
new file mode 100644
index 0000000..e73ca3c
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// typedef pthread_cond_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_same<std::condition_variable::native_handle_type,
+                                pthread_cond_t*>::value), "");
+    std::condition_variable cv;
+    std::condition_variable::native_handle_type h = cv.native_handle();
+    assert(h != nullptr);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp
new file mode 100644
index 0000000..a652f2a
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/notify_all.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_all();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    t1.join();
+    t2.join();
+    assert(test1 == 2);
+    assert(test2 == 2);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
new file mode 100644
index 0000000..55c7073
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
new file mode 100644
index 0000000..793278d
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void wait(unique_lock<mutex>& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 != 0);
+}
+
+int main()
+{
+    std::unique_lock<std::mutex>lk(mut);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
new file mode 100644
index 0000000..ebe8510
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period>
+//     cv_status
+//     wait_for(unique_lock<mutex>& lock,
+//              const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    while (test2 == 0 &&
+           cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(5));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
new file mode 100644
index 0000000..d2cf615
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period, class Predicate>
+//     bool
+//     wait_for(unique_lock<mutex>& lock,
+//              const chrono::duration<Rep, Period>& rel_time,
+//              Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(2));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
new file mode 100644
index 0000000..7aea96f
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Predicate>
+//   void wait(unique_lock<mutex>& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    cv.wait(lk, Pred(test2));
+    assert(test2 != 0);
+}
+
+int main()
+{
+    std::unique_lock<std::mutex>lk(mut);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
new file mode 100644
index 0000000..921891d
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration>
+//   cv_status
+//   wait_until(unique_lock<mutex>& lock,
+//              const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_monotonic =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                monotonic_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(5));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
new file mode 100644
index 0000000..0eb4825
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration, class Predicate>
+//     bool
+//     wait_until(unique_lock<mutex>& lock,
+//                const chrono::time_point<Clock, Duration>& abs_time,
+//                Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_monotonic =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                monotonic_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    bool r = cv.wait_until(lk, t, Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+        assert(r);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(2));
+        assert(test2 == 0);
+        assert(!r);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp b/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
new file mode 100644
index 0000000..539140d
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv0;
+    std::condition_variable_any cv1;
+    cv1 = cv0;
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp b/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
new file mode 100644
index 0000000..dc3971d
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv0;
+    std::condition_variable_any cv1(cv0);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
new file mode 100644
index 0000000..71fa472
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv;
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
new file mode 100644
index 0000000..f891816
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// ~condition_variable_any();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any* cv;
+std::mutex m;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+    m.lock();
+    f_ready = true;
+    cv->notify_one();
+    delete cv;
+    m.unlock();
+}
+
+void g()
+{
+    m.lock();
+    g_ready = true;
+    cv->notify_one();
+    while (!f_ready)
+        cv->wait(m);
+    m.unlock();
+}
+
+int main()
+{
+    cv = new std::condition_variable_any;
+    std::thread th2(g);
+    m.lock();
+    while (!g_ready)
+        cv->wait(m);
+    m.unlock();
+    std::thread th1(f);
+    th1.join();
+    th2.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
new file mode 100644
index 0000000..1620239
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    L1 lk(m0);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        L1 lk(m0);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_all();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    t1.join();
+    t2.join();
+    assert(test1 == 2);
+    assert(test2 == 2);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
new file mode 100644
index 0000000..9d6f25e
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    L1 lk(m0);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        L1 lk(m0);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
new file mode 100644
index 0000000..ac36012
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock>
+//   void wait(Lock& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 != 0);
+}
+
+int main()
+{
+    L1 lk(m0);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
new file mode 100644
index 0000000..d9108e7
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period>
+//   cv_status
+//   wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    while (test2 == 0 &&
+           cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(5));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
new file mode 100644
index 0000000..5a30c84
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period, class Predicate>
+//   bool
+//   wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time,
+//            Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(2));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
new file mode 100644
index 0000000..d764458
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Predicate>
+//   void wait(Lock& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    cv.wait(lk, Pred(test2));
+    assert(test2 != 0);
+}
+
+int main()
+{
+    L1 lk(m0);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
new file mode 100644
index 0000000..145ec87
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Clock, class Duration>
+//   cv_status
+//   wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_monotonic =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                monotonic_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(5));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp b/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
new file mode 100644
index 0000000..8cc94d7
--- /dev/null
+++ b/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Duration, class Predicate>
+//     bool
+//     wait_until(Lock& lock,
+//                const chrono::time_point<Clock, Duration>& abs_time,
+//                Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_monotonic =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                monotonic_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    bool r = cv.wait_until(lk, t, Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+        assert(r);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(2));
+        assert(test2 == 0);
+        assert(!r);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.condition/version.pass.cpp b/test/thread/thread.condition/version.pass.cpp
new file mode 100644
index 0000000..e252025
--- /dev/null
+++ b/test/thread/thread.condition/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+#include <condition_variable>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/thread/thread.general/nothing_to_do.pass.cpp b/test/thread/thread.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
new file mode 100644
index 0000000..df3e7fb
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
@@ -0,0 +1,505 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+//   void lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+    bool locked_;
+
+public:
+    L0() : locked_(false) {}
+
+    void lock()
+    {
+        locked_ = true;
+    }
+
+    bool try_lock()
+    {
+        locked_ = true;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L1
+{
+    bool locked_;
+
+public:
+    L1() : locked_(false) {}
+
+    void lock()
+    {
+        locked_ = true;
+    }
+
+    bool try_lock()
+    {
+        locked_ = false;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L2
+{
+    bool locked_;
+
+public:
+    L2() : locked_(false) {}
+
+    void lock()
+    {
+        throw 1;
+    }
+
+    bool try_lock()
+    {
+        throw 1;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+int main()
+{
+    {
+        L0 l0;
+        L0 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L1 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L2 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+#endif
+}
diff --git a/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
new file mode 100644
index 0000000..121fc6d
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
@@ -0,0 +1,516 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+//   int try_lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+    bool locked_;
+
+public:
+    L0() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = true;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L1
+{
+    bool locked_;
+
+public:
+    L1() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = false;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L2
+{
+    bool locked_;
+
+public:
+    L2() : locked_(false) {}
+
+    bool try_lock()
+    {
+        throw 1;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+
+
+int main()
+{
+    {
+        L0 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        assert(std::try_lock(l0, l1) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L1 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 3);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+#endif
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
new file mode 100644
index 0000000..868f7a4
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    m.lock();
+    std::lock_guard<std::mutex> lg(m, std::adopt_lock);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
new file mode 100644
index 0000000..2828c4f
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard& operator=(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    std::lock_guard<std::mutex> lg0(m0);
+    std::lock_guard<std::mutex> lg(m1);
+    lg = lg0;
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
new file mode 100644
index 0000000..5c0433b
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+    std::lock_guard<std::mutex> lg0(m);
+    std::lock_guard<std::mutex> lg(lg0);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
new file mode 100644
index 0000000..e1e781f
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg = m;
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
new file mode 100644
index 0000000..985af8e
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
new file mode 100644
index 0000000..1482b58
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex>
+// class lock_guard
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::lock_guard<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
new file mode 100644
index 0000000..3f3d15d
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = lk0;
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
new file mode 100644
index 0000000..11b6dc5
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = lk0;
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
new file mode 100644
index 0000000..c062845
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::unique_lock<std::mutex> ul;
+    assert(!ul.owns_lock());
+    assert(ul.mutex() == nullptr);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..d64c4b2
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = std::move(lk0);
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
new file mode 100644
index 0000000..a4dd897
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = std::move(lk0);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
new file mode 100644
index 0000000..0bdecbb
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit unique_lock(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::unique_lock<std::mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
new file mode 100644
index 0000000..96bc512
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+
+
+int main()
+{
+    std::mutex m;
+    m.lock();
+    std::unique_lock<std::mutex> lk(m, std::adopt_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
new file mode 100644
index 0000000..5cd591d
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, defer_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+
+
+int main()
+{
+    std::mutex m;
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == false);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
new file mode 100644
index 0000000..b55404f
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//   unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
new file mode 100644
index 0000000..82623e5
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//   unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
new file mode 100644
index 0000000..383cbf5
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, try_to_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    while (true)
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        if (lk.owns_lock())
+            break;
+    }
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
new file mode 100644
index 0000000..158a772
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    time_point t0 = Clock::now();
+    lk.lock();
+    time_point t1 = Clock::now();
+    assert(lk.owns_lock() == true);
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    lk.release();
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
new file mode 100644
index 0000000..b055c8f
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool try_lock();
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_called = false;
+
+struct mutex
+{
+    bool try_lock()
+    {
+        try_lock_called = !try_lock_called;
+        return try_lock_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock() == true);
+    assert(try_lock_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock() == false);
+    assert(try_lock_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
new file mode 100644
index 0000000..7ee9994
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+//   bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+    template <class Rep, class Period>
+        bool try_lock_for(const std::chrono::duration<Rep, Period>& rel_time)
+    {
+        assert(rel_time == ms(5));
+        try_lock_for_called = !try_lock_for_called;
+        return try_lock_for_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_for(ms(5)) == true);
+    assert(try_lock_for_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_for(ms(5)) == false);
+    assert(try_lock_for_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
new file mode 100644
index 0000000..2557978
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+//   bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+    template <class Clock, class Duration>
+        bool try_lock_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+    {
+        typedef std::chrono::milliseconds ms;
+        assert(Clock::now() - abs_time < ms(5));
+        try_lock_until_called = !try_lock_until_called;
+        return try_lock_until_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    typedef std::chrono::monotonic_clock Clock;
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_until(Clock::now()) == true);
+    assert(try_lock_until_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_until(Clock::now()) == false);
+    assert(try_lock_until_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
new file mode 100644
index 0000000..bcdb6a5
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void unlock();
+
+#include <mutex>
+#include <cassert>
+
+bool unlock_called = false;
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {unlock_called = true;}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    lk.unlock();
+    assert(unlock_called == true);
+    assert(lk.owns_lock() == false);
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+    lk.release();
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
new file mode 100644
index 0000000..ee9820a
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    lk1.swap(lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..1ebeb2b
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Mutex>
+//   void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    swap(lk1, lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
new file mode 100644
index 0000000..dab100d
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    static int lock_count;
+    static int unlock_count;
+    void lock() {++lock_count;}
+    void unlock() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    assert(lk.release() == &m);
+    assert(lk.mutex() == nullptr);
+    assert(lk.owns_lock() == false);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
new file mode 100644
index 0000000..3adb313
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type *mutex() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.mutex() == nullptr);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.mutex() == &m);
+    lk1.unlock();
+    assert(lk1.mutex() == &m);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
new file mode 100644
index 0000000..70f8466
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0 == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1 == true);
+    lk1.unlock();
+    assert(lk1 == false);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
new file mode 100644
index 0000000..8b0e451
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool owns_lock() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.owns_lock() == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.owns_lock() == true);
+    lk1.unlock();
+    assert(lk1.owns_lock() == false);
+}
diff --git a/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp b/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
new file mode 100644
index 0000000..a8d0536
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex>
+// class unique_lock
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::unique_lock<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}
diff --git a/test/thread/thread.mutex/thread.lock/types.pass.cpp b/test/thread/thread.mutex/thread.lock/types.pass.cpp
new file mode 100644
index 0000000..080f900
--- /dev/null
+++ b/test/thread/thread.mutex/thread.lock/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct defer_lock_t {};
+// struct try_to_lock_t {};
+// struct adopt_lock_t {};
+// 
+// constexpr defer_lock_t  defer_lock{};
+// constexpr try_to_lock_t try_to_lock{};
+// constexpr adopt_lock_t  adopt_lock{};
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    typedef std::defer_lock_t T1;
+    typedef std::try_to_lock_t T2;
+    typedef std::adopt_lock_t T3;
+
+    T1 t1 = std::defer_lock;
+    T2 t2 = std::try_to_lock;
+    T3 t3 = std::adopt_lock;
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/assign.fail.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/assign.fail.cpp
new file mode 100644
index 0000000..cdd0c66
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex& operator=(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    m1 = m0;
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/copy.fail.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/copy.fail.cpp
new file mode 100644
index 0000000..413a44c
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1(m0);
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/default.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/default.pass.cpp
new file mode 100644
index 0000000..9953a00
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/lock.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/lock.pass.cpp
new file mode 100644
index 0000000..d017b68
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/lock.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/native_handle.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/native_handle.pass.cpp
new file mode 100644
index 0000000..bd939d0
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/native_handle.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/try_lock.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/try_lock.pass.cpp
new file mode 100644
index 0000000..0b6b935
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.class/try_lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/assign.fail.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/assign.fail.cpp
new file mode 100644
index 0000000..1ce28f0
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1;
+    m1 = m0;
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/copy.fail.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/copy.fail.cpp
new file mode 100644
index 0000000..ee2e34d
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1(m0);
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/default.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/default.pass.cpp
new file mode 100644
index 0000000..c0e2df0
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m;
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/lock.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/lock.pass.cpp
new file mode 100644
index 0000000..d9d43e5
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/native_handle.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/native_handle.pass.cpp
new file mode 100644
index 0000000..fd975fd
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/native_handle.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::recursive_mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}
diff --git a/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/try_lock.pass.cpp b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/try_lock.pass.cpp
new file mode 100644
index 0000000..217934b
--- /dev/null
+++ b/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp b/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
new file mode 100644
index 0000000..261960e
--- /dev/null
+++ b/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// template<class Callable, class ...Args>
+//   void call_once(once_flag& flag, Callable func, Args&&... args);
+
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+std::once_flag flg0;
+
+int init0_called = 0;
+
+void init0()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init0_called;
+}
+
+void f0()
+{
+    std::call_once(flg0, init0);
+}
+
+std::once_flag flg3;
+
+int init3_called = 0;
+int init3_completed = 0;
+
+void init3()
+{
+    ++init3_called;
+    std::this_thread::sleep_for(ms(250));
+    if (init3_called == 1)
+        throw 1;
+    ++init3_completed;
+}
+
+void f3()
+{
+    try
+    {
+        std::call_once(flg3, init3);
+    }
+    catch (...)
+    {
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+struct init1
+{
+    static int called;
+
+    void operator()(int i) {called += i;}
+};
+
+int init1::called = 0;
+
+std::once_flag flg1;
+
+void f1()
+{
+    std::call_once(flg1, init1(), 1);
+}
+
+struct init2
+{
+    static int called;
+
+    void operator()(int i, int j) const {called += i + j;}
+};
+
+int init2::called = 0;
+
+std::once_flag flg2;
+
+void f2()
+{
+    std::call_once(flg2, init2(), 2, 3);
+    std::call_once(flg2, init2(), 4, 5);
+}
+
+#endif
+
+std::once_flag flg41;
+std::once_flag flg42;
+
+int init41_called = 0;
+int init42_called = 0;
+
+void init42();
+
+void init41()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init41_called;
+}
+
+void init42()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init42_called;
+}
+
+void f41()
+{
+    std::call_once(flg41, init41);
+    std::call_once(flg42, init42);
+}
+
+void f42()
+{
+    std::call_once(flg42, init42);
+    std::call_once(flg41, init41);
+}
+
+
+int main()
+{
+    // check basic functionality
+    {
+        std::thread t0(f0);
+        std::thread t1(f0);
+        t0.join();
+        t1.join();
+        assert(init0_called == 1);
+    }
+    // check basic exception safety
+    {
+        std::thread t0(f3);
+        std::thread t1(f3);
+        t0.join();
+        t1.join();
+        assert(init3_called == 2);
+        assert(init3_completed == 1);
+    }
+    // check deadlock avoidance
+    {
+        std::thread t0(f41);
+        std::thread t1(f42);
+        t0.join();
+        t1.join();
+        assert(init41_called == 1);
+        assert(init42_called == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    // check functors with 1 arg
+    {
+        std::thread t0(f1);
+        std::thread t1(f1);
+        t0.join();
+        t1.join();
+        assert(init1::called == 1);
+    }
+    // check functors with 2 args
+    {
+        std::thread t0(f2);
+        std::thread t1(f2);
+        t0.join();
+        t1.join();
+        assert(init2::called == 5);
+    }
+#endif
+}
diff --git a/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp b/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
new file mode 100644
index 0000000..8722736
--- /dev/null
+++ b/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag& operator=(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2;
+    f2 = f;
+}
diff --git a/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp b/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
new file mode 100644
index 0000000..b731476
--- /dev/null
+++ b/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2(f);
+}
diff --git a/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp b/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
new file mode 100644
index 0000000..1b2d172
--- /dev/null
+++ b/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// constexpr once_flag();
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
new file mode 100644
index 0000000..7d1746a
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex& operator=(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1;
+    m1 = m0;
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
new file mode 100644
index 0000000..04aee61
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1(m0);
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
new file mode 100644
index 0000000..501f7df
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m;
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
new file mode 100644
index 0000000..25eec67
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
new file mode 100644
index 0000000..b775aa2
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
new file mode 100644
index 0000000..ea05212
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
new file mode 100644
index 0000000..78735e4
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
new file mode 100644
index 0000000..399523e
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1;
+    m1 = m0;
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
new file mode 100644
index 0000000..208c8d6
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1(m0);
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
new file mode 100644
index 0000000..7b0ffd2
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m;
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
new file mode 100644
index 0000000..3caf7dd
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
new file mode 100644
index 0000000..95c31d7
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
new file mode 100644
index 0000000..730467a
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
new file mode 100644
index 0000000..9d31bca
--- /dev/null
+++ b/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::monotonic_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(5000000));  // within 5ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/test/thread/thread.mutex/version.pass.cpp b/test/thread/thread.mutex/version.pass.cpp
new file mode 100644
index 0000000..c25e8c8
--- /dev/null
+++ b/test/thread/thread.mutex/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+#include <mutex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/thread/thread.req/nothing_to_do.pass.cpp b/test/thread/thread.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp b/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp b/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp b/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp b/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
new file mode 100644
index 0000000..b72590e
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void swap(thread& x, thread& y);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        swap(t0, t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
new file mode 100644
index 0000000..ec8f1fb
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0(G());
+        std::thread t1;
+        t1 = t0;
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
new file mode 100644
index 0000000..d7f5ad3
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    std::set_terminate(f1);
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    {
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t0 = std::move(t1);
+        assert(false);
+    }
+#endif
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
new file mode 100644
index 0000000..f10b25c
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_one == 0)
+        throw std::bad_alloc();
+    --throw_one;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+bool f_run = false;
+
+void f()
+{
+    f_run = true;
+}
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t(f);
+        t.join();
+        assert(f_run == true);
+    }
+    f_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            std::thread t(f);
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(!f_run);
+        }
+    }
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    G::op_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+            std::thread t((G()));
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t(G(), 5, 5.5);
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+#endif
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
new file mode 100644
index 0000000..3308484
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(const thread&) = delete;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = t0;
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
new file mode 100644
index 0000000..352e813
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread t;
+    assert(t.get_id() == std::thread::id());
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
new file mode 100644
index 0000000..254cca0
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+#endif
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
new file mode 100644
index 0000000..d926795
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// ~thread();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_terminate(f1);
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+    }
+    assert(false);
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
new file mode 100644
index 0000000..61a771d
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id& operator=(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert(id1 == id0);
+    id1 = std::this_thread::get_id();
+    assert(id1 != id0);
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
new file mode 100644
index 0000000..5630dc9
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1 = id0;
+    assert(id1 == id0);
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
new file mode 100644
index 0000000..77b839a
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id;
+    assert(id == std::thread::id());
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
new file mode 100644
index 0000000..46246a2
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// bool operator==(thread::id x, thread::id y);
+// bool operator!=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert( (id1 == id0));
+    assert(!(id1 != id0));
+    id1 = std::this_thread::get_id();
+    assert(!(id1 == id0));
+    assert( (id1 != id0));
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
new file mode 100644
index 0000000..a98dbdc
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// bool operator< (thread::id x, thread::id y);
+// bool operator<=(thread::id x, thread::id y);
+// bool operator> (thread::id x, thread::id y);
+// bool operator>=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    assert(!(id0 <  id1));
+    assert( (id0 <= id1));
+    assert(!(id0 >  id1));
+    assert( (id0 >= id1));
+    assert( (id0 <  id2));
+    assert( (id0 <= id2));
+    assert(!(id0 >  id2));
+    assert(!(id0 >= id2));
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
new file mode 100644
index 0000000..fb0e4e9
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+#include <thread>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0 = std::this_thread::get_id();
+    std::ostringstream os;
+    os << id0;
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
new file mode 100644
index 0000000..054a362
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    typedef std::hash<std::thread::id> H;
+    H h;
+    assert(h(id1) != h(id2));
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
new file mode 100644
index 0000000..081a98f
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void detach();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.detach();
+        assert(!t0.joinable());
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+        assert(G::op_run);
+        assert(G::n_alive == 0);
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
new file mode 100644
index 0000000..c5c7788
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// id get_id() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        assert(t0.get_id() != id1);
+        assert(t1.get_id() == std::thread::id());
+        t0.join();
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
new file mode 100644
index 0000000..c890f18
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void join();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
new file mode 100644
index 0000000..1b24796
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// bool joinable() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
new file mode 100644
index 0000000..63c879b
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        pthread_t pid = t0.native_handle();
+        assert(pid != 0);
+        t0.join();
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
new file mode 100644
index 0000000..61aee10
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void swap(thread& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive == 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        t0.swap(t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}
diff --git a/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp b/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
new file mode 100644
index 0000000..3f52060
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// unsigned hardware_concurrency();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    assert(std::thread::hardware_concurrency() > 0);
+}
diff --git a/test/thread/thread.threads/thread.thread.class/types.pass.cpp b/test/thread/thread.threads/thread.thread.class/types.pass.cpp
new file mode 100644
index 0000000..b547675
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+// {
+// public:
+//     typedef pthread_t native_handle_type;
+//     ...
+// };
+
+#include <thread>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+}
diff --git a/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp b/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp
new file mode 100644
index 0000000..d8391a6
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// thread::id this_thread::get_id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id = std::this_thread::get_id();
+    assert(id != std::thread::id());
+}
diff --git a/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
new file mode 100644
index 0000000..1340785
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.this/sleep_for.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// template <class Rep, class Period>
+//   void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_for(ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = ms / 100;
+    // The time slept is within 1% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}
diff --git a/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp b/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
new file mode 100644
index 0000000..c117e12
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.this/sleep_until.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// template <class Clock, class Duration>
+//   void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_until(t0 + ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = ms / 100;
+    // The time slept is within 1% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}
diff --git a/test/thread/thread.threads/thread.thread.this/yield.pass.cpp b/test/thread/thread.threads/thread.thread.this/yield.pass.cpp
new file mode 100644
index 0000000..fcbd358
--- /dev/null
+++ b/test/thread/thread.threads/thread.thread.this/yield.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// void this_thread::yield();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::this_thread::yield();
+}
diff --git a/test/thread/thread.threads/version.pass.cpp b/test/thread/thread.threads/version.pass.cpp
new file mode 100644
index 0000000..3ce8866
--- /dev/null
+++ b/test/thread/thread.threads/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+#include <thread>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/utilities/date.time/tested_elsewhere.pass.cpp b/test/utilities/date.time/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..c9f667c
--- /dev/null
+++ b/test/utilities/date.time/tested_elsewhere.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
new file mode 100644
index 0000000..1b05252
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
new file mode 100644
index 0000000..0667c9b
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
new file mode 100644
index 0000000..4d8b415
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
new file mode 100644
index 0000000..4a92ef3
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
new file mode 100644
index 0000000..832e5b0
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
new file mode 100644
index 0000000..6a6e07e
--- /dev/null
+++ b/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/base/nothing_to_do.pass.cpp b/test/utilities/function.objects/base/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/function.objects/base/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..e93043e
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
new file mode 100644
index 0000000..8f87a0d
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
new file mode 100644
index 0000000..1340a0c
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..0eb0c06
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
new file mode 100644
index 0000000..341cf27
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
new file mode 100644
index 0000000..eebe80b
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
new file mode 100644
index 0000000..5b54c24
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp b/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bind/nothing_to_do.pass.cpp b/test/utilities/function.objects/bind/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/function.objects/bind/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
new file mode 100644
index 0000000..6addf35
--- /dev/null
+++ b/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
new file mode 100644
index 0000000..ef54684
--- /dev/null
+++ b/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
new file mode 100644
index 0000000..139763d
--- /dev/null
+++ b/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/equal_to.pass.cpp b/test/utilities/function.objects/comparisons/equal_to.pass.cpp
new file mode 100644
index 0000000..55796f8
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/equal_to.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/greater.pass.cpp b/test/utilities/function.objects/comparisons/greater.pass.cpp
new file mode 100644
index 0000000..ee36c53
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/greater.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/greater_equal.pass.cpp b/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
new file mode 100644
index 0000000..a6d114c
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/less.pass.cpp b/test/utilities/function.objects/comparisons/less.pass.cpp
new file mode 100644
index 0000000..6a40ba0
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/less.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/less_equal.pass.cpp b/test/utilities/function.objects/comparisons/less_equal.pass.cpp
new file mode 100644
index 0000000..8497670
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/less_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
new file mode 100644
index 0000000..fb99ee5
--- /dev/null
+++ b/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp b/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_data.fail.cpp b/test/utilities/function.objects/func.memfn/member_data.fail.cpp
new file mode 100644
index 0000000..4cc6644
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_data.fail.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_data.pass.cpp b/test/utilities/function.objects/func.memfn/member_data.pass.cpp
new file mode 100644
index 0000000..303097e
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_data.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_function.pass.cpp b/test/utilities/function.objects/func.memfn/member_function.pass.cpp
new file mode 100644
index 0000000..774a507
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_function.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
new file mode 100644
index 0000000..b8b24d9
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
new file mode 100644
index 0000000..9523f53
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp b/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
new file mode 100644
index 0000000..bf028b3
--- /dev/null
+++ b/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.require/binary_function.pass.cpp b/test/utilities/function.objects/func.require/binary_function.pass.cpp
new file mode 100644
index 0000000..e03dfe2
--- /dev/null
+++ b/test/utilities/function.objects/func.require/binary_function.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.require/unary_function.pass.cpp b/test/utilities/function.objects/func.require/unary_function.pass.cpp
new file mode 100644
index 0000000..b5c944c
--- /dev/null
+++ b/test/utilities/function.objects/func.require/unary_function.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
new file mode 100644
index 0000000..22af67e
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
new file mode 100644
index 0000000..682399a
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
new file mode 100644
index 0000000..b21c552
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
new file mode 100644
index 0000000..6ecb531
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
new file mode 100644
index 0000000..1cce025
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
new file mode 100644
index 0000000..9b090f3
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
new file mode 100644
index 0000000..bf2b331
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class A> function(allocator_arg_t, const A&); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
new file mode 100644
index 0000000..e3a1e7b
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> function(allocator_arg_t, const A&, F);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class F, class A> function(allocator_arg_t, const A&, F); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
new file mode 100644
index 0000000..3b55eb8
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, const function&);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class A> function(allocator_arg_t, const A&, const function&); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
new file mode 100644
index 0000000..28edd85
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class A> function(allocator_arg_t, const A&, nullptr_t); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
new file mode 100644
index 0000000..2facbf7
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, function&&);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class A> function(allocator_arg_t, const A&, function&&); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
new file mode 100644
index 0000000..78dcc58
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
new file mode 100644
index 0000000..2b16806
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
new file mode 100644
index 0000000..b63544f
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
new file mode 100644
index 0000000..e493ccf
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
new file mode 100644
index 0000000..4361d4a
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
new file mode 100644
index 0000000..e3626ef
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
new file mode 100644
index 0000000..4babee7
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..6bab12a
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..5df2606
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
new file mode 100644
index 0000000..bbb84aa
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> void assign(F&&, const A&);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#error template<class F, class A> void assign(F&&, const A&); not implemented
+}
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
new file mode 100644
index 0000000..1e19ee2
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
new file mode 100644
index 0000000..8a2ae86
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
new file mode 100644
index 0000000..53fa50b
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
new file mode 100644
index 0000000..08abfad
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
new file mode 100644
index 0000000..17a8794
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp b/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp
new file mode 100644
index 0000000..f3f2c0a
--- /dev/null
+++ b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_binary_function.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp
new file mode 100644
index 0000000..70a9ceb
--- /dev/null
+++ b/test/utilities/function.objects/function.pointer.adaptors/pointer_to_unary_function.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp
new file mode 100644
index 0000000..4f377ef
--- /dev/null
+++ b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp
new file mode 100644
index 0000000..93c6376
--- /dev/null
+++ b/test/utilities/function.objects/function.pointer.adaptors/ptr_fun2.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/logical.operations/logical_and.pass.cpp b/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
new file mode 100644
index 0000000..e193c90
--- /dev/null
+++ b/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/logical.operations/logical_not.pass.cpp b/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
new file mode 100644
index 0000000..16bb419
--- /dev/null
+++ b/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/logical.operations/logical_or.pass.cpp b/test/utilities/function.objects/logical.operations/logical_or.pass.cpp
new file mode 100644
index 0000000..0f2518a
--- /dev/null
+++ b/test/utilities/function.objects/logical.operations/logical_or.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp
new file mode 100644
index 0000000..b206b00
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp
new file mode 100644
index 0000000..c2d6407
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
new file mode 100644
index 0000000..933842e
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp
new file mode 100644
index 0000000..8071810
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun1_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp
new file mode 100644
index 0000000..d8c3dbb
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
new file mode 100644
index 0000000..5cba2c9
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
new file mode 100644
index 0000000..f28a36a
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp
new file mode 100644
index 0000000..fdcd440
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/const_mem_fun_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp
new file mode 100644
index 0000000..0ea08e8
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp
new file mode 100644
index 0000000..e47fb6c
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
new file mode 100644
index 0000000..adc0059
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp
new file mode 100644
index 0000000..ab29d9a
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun1_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp
new file mode 100644
index 0000000..8d79e7a
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp
new file mode 100644
index 0000000..bbc64a1
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp
new file mode 100644
index 0000000..9a9e9dd
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_ref_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp
new file mode 100644
index 0000000..5db73e1
--- /dev/null
+++ b/test/utilities/function.objects/member.pointer.adaptors/mem_fun_t.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/negators/binary_negate.pass.cpp b/test/utilities/function.objects/negators/binary_negate.pass.cpp
new file mode 100644
index 0000000..25f7914
--- /dev/null
+++ b/test/utilities/function.objects/negators/binary_negate.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/negators/not1.pass.cpp b/test/utilities/function.objects/negators/not1.pass.cpp
new file mode 100644
index 0000000..03bb7a7
--- /dev/null
+++ b/test/utilities/function.objects/negators/not1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/negators/not2.pass.cpp b/test/utilities/function.objects/negators/not2.pass.cpp
new file mode 100644
index 0000000..1f32fb1
--- /dev/null
+++ b/test/utilities/function.objects/negators/not2.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/negators/unary_negate.pass.cpp b/test/utilities/function.objects/negators/unary_negate.pass.cpp
new file mode 100644
index 0000000..55696b8
--- /dev/null
+++ b/test/utilities/function.objects/negators/unary_negate.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/binary.pass.cpp b/test/utilities/function.objects/refwrap/binary.pass.cpp
new file mode 100644
index 0000000..3dfae3e
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/binary.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
new file mode 100644
index 0000000..c7bb7a0
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
new file mode 100644
index 0000000..c491057
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
new file mode 100644
index 0000000..a866a41
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
new file mode 100644
index 0000000..633725b
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
new file mode 100644
index 0000000..5f14140
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
new file mode 100644
index 0000000..7264e4f
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
new file mode 100644
index 0000000..db712ce
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
new file mode 100644
index 0000000..934a9a8
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
new file mode 100644
index 0000000..684b1b3
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
new file mode 100644
index 0000000..e822166
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
new file mode 100644
index 0000000..99a7fe2
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
new file mode 100644
index 0000000..79a90b2
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..283177b
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..649c5c0
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/type.pass.cpp b/test/utilities/function.objects/refwrap/type.pass.cpp
new file mode 100644
index 0000000..a151625
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/type.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/unary.pass.cpp b/test/utilities/function.objects/refwrap/unary.pass.cpp
new file mode 100644
index 0000000..c572920
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/unary.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/refwrap/weak_result.pass.cpp b/test/utilities/function.objects/refwrap/weak_result.pass.cpp
new file mode 100644
index 0000000..f0935fd
--- /dev/null
+++ b/test/utilities/function.objects/refwrap/weak_result.pass.cpp
Binary files differ
diff --git a/test/utilities/function.objects/unord.hash/floating.pass.cpp b/test/utilities/function.objects/unord.hash/floating.pass.cpp
new file mode 100644
index 0000000..003ba19
--- /dev/null
+++ b/test/utilities/function.objects/unord.hash/floating.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+#include <cmath>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    std::size_t t0 = h(0.);
+    std::size_t tn0 = h(-0.);
+    std::size_t tp1 = h(0.1);
+    std::size_t t1 = h(1);
+    std::size_t tn1 = h(-1);
+    std::size_t pinf = h(INFINITY);
+    std::size_t ninf = h(-INFINITY);
+    assert(t0 == tn0);
+    assert(t0 != tp1);
+    assert(t0 != t1);
+    assert(t0 != tn1);
+    assert(t0 != pinf);
+    assert(t0 != ninf);
+
+    assert(tp1 != t1);
+    assert(tp1 != tn1);
+    assert(tp1 != pinf);
+    assert(tp1 != ninf);
+
+    assert(t1 != tn1);
+    assert(t1 != pinf);
+    assert(t1 != ninf);
+
+    assert(tn1 != pinf);
+    assert(tn1 != ninf);
+
+    assert(pinf != ninf);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/test/utilities/function.objects/unord.hash/integral.pass.cpp b/test/utilities/function.objects/unord.hash/integral.pass.cpp
new file mode 100644
index 0000000..1e6c0d5
--- /dev/null
+++ b/test/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    for (int i = 0; i <= 5; ++i)
+    {
+        T t(i);
+        assert(h(t) == t);
+    }
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<char16_t>();
+    test<char32_t>();
+    test<wchar_t>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+}
diff --git a/test/utilities/function.objects/unord.hash/pointer.pass.cpp b/test/utilities/function.objects/unord.hash/pointer.pass.cpp
new file mode 100644
index 0000000..1a66b5b
--- /dev/null
+++ b/test/utilities/function.objects/unord.hash/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    typedef typename std::remove_pointer<T>::type type;
+    type i;
+    type j;
+    assert(h(&i) != h(&j));
+}
+
+int main()
+{
+    test<int*>();
+}
diff --git a/test/utilities/function.objects/version.pass.cpp b/test/utilities/function.objects/version.pass.cpp
new file mode 100644
index 0000000..5b53d18
--- /dev/null
+++ b/test/utilities/function.objects/version.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
new file mode 100644
index 0000000..9f37e7f
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(OuterA2&& outerAlloc,
+//                            const InnerAllocs& ...innerAllocs);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A1<int> a3(3);
+        A a(a3);
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+    }
+    A1<int>::copy_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(3));
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+    }
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(4), A2<int>(5));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A3<int>::copy_called = false;
+    A3<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(4), A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
new file mode 100644
index 0000000..de8e3ff
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
+//                                                           InnerAllocs...>& other);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A3<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
new file mode 100644
index 0000000..533c01c
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
+//                                                     InnerAllocs...>&& other);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == true);
+        assert(a2 == a1);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..02397ce
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a2 == a1);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
new file mode 100644
index 0000000..770f68a
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor();
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == false);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
new file mode 100644
index 0000000..c413df6
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
new file mode 100644
index 0000000..711d6df
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n, const_void_pointer hint);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)0);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>, A3<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)20);
+        assert(A2<int>::allocate_called == true);
+    }
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
new file mode 100644
index 0000000..f66da6b
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T, class... Args> void construct(T* p, Args&&... args);
+
+#include <memory>
+#include <cassert>
+#include <string>
+
+#include "../allocators.h"
+
+#ifdef _LIBCPP_MOVE
+
+struct B
+{
+    static bool constructed;
+
+    typedef A1<B> allocator_type;
+
+    explicit B(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 5);
+        assert(i == 6);
+        constructed = true;
+    }
+};
+
+bool B::constructed = false;
+
+struct C
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<C>> allocator_type;
+
+    explicit C(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 7);
+        assert(i == 8);
+        constructed = true;
+    }
+};
+
+bool C::constructed = false;
+
+struct D
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<D>> allocator_type;
+
+    explicit D(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 3);
+        constructed = true;
+    }
+};
+
+bool D::constructed = false;
+
+struct E
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A1<E>> allocator_type;
+
+    explicit E(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool E::constructed = false;
+
+struct F
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<F>> allocator_type;
+
+    explicit F(int i, int j)
+    {
+        assert(i == 1);
+        assert(j == 2);
+    }
+
+    explicit F(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool F::constructed = false;
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<std::string>> A;
+        A a;
+        char buf[100];
+        typedef std::string S;
+        S* s = (S*)buf;
+        a.construct(s, 4, 'c');
+        assert(*s == "cccc");
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a(A1<B>(5));
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        a.construct(s, 6);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<C>> A;
+        A a(A1<int>(5), A2<C>(7));
+        char buf[100];
+        typedef C S;
+        S* s = (S*)buf;
+        a.construct(s, 8);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<D>> A;
+        A a(A1<int>(5), A2<D>(3));
+        char buf[100];
+        typedef D S;
+        S* s = (S*)buf;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<E>, A2<E>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<E>> A;
+        A a(K(), A1<E>(50));
+        char buf[100];
+        typedef E S;
+        S* s = (S*)buf;
+        A3<E>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        assert(A3<E>::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<F>, A2<F>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<F>> A;
+        A a(K(), A1<F>(50));
+        char buf[100];
+        typedef F S;
+        S* s = (S*)buf;
+        A3<F>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(!S::constructed);
+        assert(A3<F>::constructed);
+        s->~S();
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
new file mode 100644
index 0000000..6a8b2da
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/deallocate.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// void deallocate(pointer p, size_type n);
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
new file mode 100644
index 0000000..d3af8b6
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T> void destroy(T* p);
+
+#include <memory>
+#include <cassert>
+#include <string>
+
+#include "../allocators.h"
+
+struct B
+{
+    static bool constructed;
+
+    B() {constructed = true;}
+    ~B() {constructed = false;}
+};
+
+bool B::constructed = false;
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        a.construct(s);
+        assert(S::constructed);
+        a.destroy(s);
+        assert(!S::constructed);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<B>, A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        assert(!A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.construct(s);
+        assert(S::constructed);
+        assert(A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.destroy(s);
+        assert(!S::constructed);
+        assert(A3<S>::constructed);
+        assert(A3<S>::destroy_called);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
new file mode 100644
index 0000000..5c66dde
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/inner_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// inner_allocator_type& inner_allocator();
+// const inner_allocator_type& inner_allocator() const;
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.inner_allocator() == a);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(6)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(6), A3<int>(8))));
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
new file mode 100644
index 0000000..033c6cd
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// size_type max_size() const;
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        const A a(A1<int>(100));
+        assert(a.max_size() == 100);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        const A a(A1<int>(20), A2<int>());
+        assert(a.max_size() == 20);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        const A a(A1<int>(200), A2<int>(), A3<int>());
+        assert(a.max_size() == 200);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
new file mode 100644
index 0000000..94ffd87
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/outer_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// outer_allocator_type& outer_allocator();
+// const outer_allocator_type& outer_allocator() const;
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 0000000..aa731f9
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor select_on_container_copy_construction() const;
+
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 3);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<int>> A;
+        A a1(A3<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == -1);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(1), A2<int>(2), A3<int>(3));
+        assert(a1.outer_allocator().id() == 1);
+        assert(a1.inner_allocator().outer_allocator().id() == 2);
+        assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 1);
+        assert(a2.inner_allocator().outer_allocator().id() == 2);
+        assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1);
+    }
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
new file mode 100644
index 0000000..fd5c7cf
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below inner_allocator_type;
+
+#include <memory>
+#include <type_traits>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A1<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>, A3<int>>>::value), "");
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 0000000..2fb1ee1
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_copy_assignment;
+
+#include <memory>
+#include <type_traits>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_copy_assignment,
+        std::true_type>::value), "");
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 0000000..b52e281
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_move_assignment;
+
+#include <memory>
+#include <type_traits>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 0000000..98773a4
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_swap;
+
+#include <memory>
+#include <type_traits>
+
+#include "../allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_swap,
+        std::true_type>::value), "");
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.adaptor/allocators.h b/test/utilities/memory/allocator.adaptor/allocators.h
new file mode 100644
index 0000000..7075f85
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/allocators.h
@@ -0,0 +1,176 @@
+#ifndef ALLOCATORS_H
+#define ALLOCATORS_H
+
+#include <type_traits>
+#include <utility>
+
+#ifdef _LIBCPP_MOVE
+
+template <class T>
+class A1
+{
+    int id_;
+public:
+    explicit A1(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+    static std::pair<T*, std::size_t> deallocate_called;
+
+    A1(const A1& a) : id_(a.id()) {copy_called = true;}
+    A1(A1&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U>
+        A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
+    template <class U>
+        A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
+
+    T* allocate(std::size_t n)
+    {
+        allocate_called = true;
+        return (T*)n;
+    }
+
+    void deallocate(T* p, std::size_t n)
+    {
+        deallocate_called = std::pair<T*, std::size_t>(p, n);
+    }
+
+    std::size_t max_size() const {return id_;}
+};
+
+template <class T> bool A1<T>::copy_called = false;
+template <class T> bool A1<T>::move_called = false;
+template <class T> bool A1<T>::allocate_called = false;
+template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
+
+template <class T, class U>
+inline
+bool operator==(const A1<T>& x, const A1<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A1<T>& x, const A1<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A2
+{
+    int id_;
+public:
+    explicit A2(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef unsigned size_type;
+    typedef int difference_type;
+
+    typedef std::true_type propagate_on_container_move_assignment;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+
+    A2(const A2& a) : id_(a.id()) {copy_called = true;}
+    A2(A2&& a) : id_(a.id())      {move_called = true;}
+
+    T* allocate(std::size_t n, const void* hint)
+    {
+        allocate_called = true;
+        return (T*)hint;
+    }
+};
+
+template <class T> bool A2<T>::copy_called = false;
+template <class T> bool A2<T>::move_called = false;
+template <class T> bool A2<T>::allocate_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A2<T>& x, const A2<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A2<T>& x, const A2<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A3
+{
+    int id_;
+public:
+    explicit A3(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool constructed;
+    static bool destroy_called;
+
+    A3(const A3& a) : id_(a.id()) {copy_called = true;}
+    A3(A3&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U, class ...Args>
+    void construct(U* p, Args&& ...args)
+    {
+        ::new (p) U(std::forward<Args>(args)...);
+        constructed = true;
+    }
+
+    template <class U>
+    void destroy(U* p)
+    {
+        p->~U();
+        destroy_called = true;
+    }
+
+    A3 select_on_container_copy_construction() const {return A3(-1);}
+};
+
+
+
+template <class T> bool A3<T>::copy_called = false;
+template <class T> bool A3<T>::move_called = false;
+template <class T> bool A3<T>::constructed = false;
+template <class T> bool A3<T>::destroy_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A3<T>& x, const A3<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A3<T>& x, const A3<U>& y)
+{
+    return !(x == y);
+}
+
+#endif
+
+#endif
diff --git a/test/utilities/memory/allocator.adaptor/types.pass.cpp b/test/utilities/memory/allocator.adaptor/types.pass.cpp
new file mode 100644
index 0000000..ebac49a
--- /dev/null
+++ b/test/utilities/memory/allocator.adaptor/types.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+//     : public OuterAlloc
+// {
+// public:
+//     typedef OuterAlloc outer_allocator_type;
+//     typedef typename OuterTraits::size_type size_type;
+//     typedef typename OuterTraits::difference_type difference_type;
+//     typedef typename OuterTraits::pointer pointer;
+//     typedef typename OuterTraits::const_pointer const_pointer;
+//     typedef typename OuterTraits::void_pointer void_pointer;
+//     typedef typename OuterTraits::const_void_pointer const_void_pointer;
+// };
+
+#include <memory>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+
+    static_assert((std::is_base_of<
+        A1<int>,
+        std::scoped_allocator_adaptor<A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
+        A1<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::size_type,
+        std::size_t>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::difference_type,
+        std::ptrdiff_t>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+
+    static_assert((std::is_base_of<
+        A2<int>,
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
+        A2<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
+        unsigned>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
+        int>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+#endif
+}
diff --git a/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp b/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp
new file mode 100644
index 0000000..ad19abb
--- /dev/null
+++ b/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
new file mode 100644
index 0000000..2fb633b
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
new file mode 100644
index 0000000..4613b60
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
new file mode 100644
index 0000000..4a66255
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
new file mode 100644
index 0000000..4c648e1
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
new file mode 100644
index 0000000..282c708
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
new file mode 100644
index 0000000..1f85bd2
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 0000000..5a7df84
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
new file mode 100644
index 0000000..cab032c
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
new file mode 100644
index 0000000..0fcc13c
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000..20cc70f
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
new file mode 100644
index 0000000..bd2ddc4
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 0000000..83be6e3
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 0000000..1c25b7f
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 0000000..6abc1cd
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
new file mode 100644
index 0000000..c342835
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
new file mode 100644
index 0000000..a0bb3d1
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
new file mode 100644
index 0000000..4efa5ab
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/allocator_type.pass.cpp b/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
new file mode 100644
index 0000000..0c8a21e
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
new file mode 100644
index 0000000..9605a12
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.traits/value_type.pass.cpp b/test/utilities/memory/allocator.traits/value_type.pass.cpp
new file mode 100644
index 0000000..9070ed2
--- /dev/null
+++ b/test/utilities/memory/allocator.traits/value_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp b/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
new file mode 100644
index 0000000..12b1406
--- /dev/null
+++ b/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp b/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp b/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..4c1f61c
--- /dev/null
+++ b/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp b/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
new file mode 100644
index 0000000..fd46264
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp b/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp
new file mode 100644
index 0000000..a434c7e
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
new file mode 100644
index 0000000..9856770
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
new file mode 100644
index 0000000..6718d10
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
new file mode 100644
index 0000000..b6736ec
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator_types.pass.cpp b/test/utilities/memory/default.allocator/allocator_types.pass.cpp
new file mode 100644
index 0000000..e3ac765
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator_types.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/default.allocator/allocator_void.pass.cpp b/test/utilities/memory/default.allocator/allocator_void.pass.cpp
new file mode 100644
index 0000000..9d948fb
--- /dev/null
+++ b/test/utilities/memory/default.allocator/allocator_void.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/difference_type.pass.cpp b/test/utilities/memory/pointer.traits/difference_type.pass.cpp
new file mode 100644
index 0000000..23a5b47
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/difference_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/element_type.pass.cpp b/test/utilities/memory/pointer.traits/element_type.pass.cpp
new file mode 100644
index 0000000..e329842
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/element_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer.pass.cpp b/test/utilities/memory/pointer.traits/pointer.pass.cpp
new file mode 100644
index 0000000..898a54a
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
new file mode 100644
index 0000000..c43fbf6
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000..baa3538
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
new file mode 100644
index 0000000..defdb99
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
new file mode 100644
index 0000000..19178c5
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/pointer_to.pass.cpp b/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
new file mode 100644
index 0000000..28dc3f2
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/pointer.traits/rebind.pass.cpp b/test/utilities/memory/pointer.traits/rebind.pass.cpp
new file mode 100644
index 0000000..c60cbd4
--- /dev/null
+++ b/test/utilities/memory/pointer.traits/rebind.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/ptr.align/align.pass.cpp b/test/utilities/memory/ptr.align/align.pass.cpp
new file mode 100644
index 0000000..85558da
--- /dev/null
+++ b/test/utilities/memory/ptr.align/align.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// #include <memory>
+
+// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    const unsigned N = 20;
+    char buf[N];
+    void* r;
+    void* p = &buf[0];
+    std::size_t s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-3);
+
+    p = &buf[2];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-2);
+
+    p = &buf[3];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-1);
+
+    p = &buf[4];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(4, N, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-4, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-4);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-3, p, s);
+    assert(p == &buf[1]);
+    assert(r == nullptr);
+    assert(s == N-1);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(1, N+1, p, s);
+    assert(p == &buf[0]);
+    assert(r == nullptr);
+    assert(s == N);
+}
diff --git a/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp b/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp b/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
new file mode 100644
index 0000000..3eb0928
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
new file mode 100644
index 0000000..dd94c51
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
new file mode 100644
index 0000000..0bc3e25
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
new file mode 100644
index 0000000..0357859
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
new file mode 100644
index 0000000..843eece
--- /dev/null
+++ b/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
new file mode 100644
index 0000000..8e3f145
--- /dev/null
+++ b/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
new file mode 100644
index 0000000..40beea8
--- /dev/null
+++ b/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/deleter.h b/test/utilities/memory/unique.ptr/deleter.h
new file mode 100644
index 0000000..6c5c9a4
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/deleter.h
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
new file mode 100644
index 0000000..4fe3a66
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
new file mode 100644
index 0000000..26bd82a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
new file mode 100644
index 0000000..f259c7c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
new file mode 100644
index 0000000..7084e34
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
new file mode 100644
index 0000000..e83346e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
new file mode 100644
index 0000000..120306f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
new file mode 100644
index 0000000..cd29056
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
new file mode 100644
index 0000000..2524f3b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
new file mode 100644
index 0000000..030a53c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
new file mode 100644
index 0000000..2c2fdd9
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
new file mode 100644
index 0000000..dc0b46e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
new file mode 100644
index 0000000..0d7cfe8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
new file mode 100644
index 0000000..7a74137
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
new file mode 100644
index 0000000..84faeb3
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
new file mode 100644
index 0000000..81d7e49
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
new file mode 100644
index 0000000..7043146
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
new file mode 100644
index 0000000..7ade7c8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
new file mode 100644
index 0000000..cf5c6d1
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
new file mode 100644
index 0000000..2337053
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
new file mode 100644
index 0000000..a21e545
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
new file mode 100644
index 0000000..be3292a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
new file mode 100644
index 0000000..d133152
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
new file mode 100644
index 0000000..a4f5540
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
new file mode 100644
index 0000000..9d0e40f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
new file mode 100644
index 0000000..ae9a015
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
new file mode 100644
index 0000000..bf375a5
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
new file mode 100644
index 0000000..5edf3f8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
new file mode 100644
index 0000000..5229a90
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
new file mode 100644
index 0000000..7f8cc0f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
new file mode 100644
index 0000000..72a7449
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
new file mode 100644
index 0000000..9436320
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
new file mode 100644
index 0000000..8c11b51
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
new file mode 100644
index 0000000..4b0a5fd
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
new file mode 100644
index 0000000..f2a8263
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
new file mode 100644
index 0000000..8c77d47
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000..9f07dec
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000..5217a86
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000..2e562d8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000..e2d2422
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000..d7d5e16
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000..6765031
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000..136857d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000..b65ad1f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000..dabe4ac
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000..780c392
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000..f16ea7b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000..7b0a42c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000..5a5d917
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
new file mode 100644
index 0000000..96ae4bd
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
new file mode 100644
index 0000000..abf31eb
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
new file mode 100644
index 0000000..0e4e64f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
new file mode 100644
index 0000000..ab772bd
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
new file mode 100644
index 0000000..c54882b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000..e291d98
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000..1aabf21
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000..de0cd26
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000..aa01ffd
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000..4146d56
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000..e826b99
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
new file mode 100644
index 0000000..6db86df
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000..ab3899e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000..6bb16db
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000..a5e7b93
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000..8350829
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000..b9c8f83
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
new file mode 100644
index 0000000..7c09b16
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
new file mode 100644
index 0000000..d3cc0bf
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000..4753b02
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
new file mode 100644
index 0000000..8466a6c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
new file mode 100644
index 0000000..0c70ce7
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
new file mode 100644
index 0000000..51747d1
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000..2325385
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
new file mode 100644
index 0000000..7496793
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000..3f4ab3f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
new file mode 100644
index 0000000..f8af29a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
new file mode 100644
index 0000000..1defbc6
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
new file mode 100644
index 0000000..d00f5b8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
new file mode 100644
index 0000000..cd29056
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
new file mode 100644
index 0000000..99b7c5e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
new file mode 100644
index 0000000..0d47e02
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
new file mode 100644
index 0000000..2c2fdd9
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
new file mode 100644
index 0000000..dc0b46e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
new file mode 100644
index 0000000..4a7a278
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
new file mode 100644
index 0000000..9319ff8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
new file mode 100644
index 0000000..c42dbf6
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
new file mode 100644
index 0000000..c2336e8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
new file mode 100644
index 0000000..b9f4933
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
new file mode 100644
index 0000000..cfdf15d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
new file mode 100644
index 0000000..7922523
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
new file mode 100644
index 0000000..3853b3f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
new file mode 100644
index 0000000..780e46d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
new file mode 100644
index 0000000..35b91f5
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
new file mode 100644
index 0000000..be3292a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
new file mode 100644
index 0000000..b405b1a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
new file mode 100644
index 0000000..8b7e497
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
new file mode 100644
index 0000000..4ca2a08
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
new file mode 100644
index 0000000..c3f955b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
new file mode 100644
index 0000000..c2b6a36
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
new file mode 100644
index 0000000..e78f652
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
new file mode 100644
index 0000000..d6ae0d7
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
new file mode 100644
index 0000000..2542d8d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
new file mode 100644
index 0000000..ea99a33
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
new file mode 100644
index 0000000..d6cfe08
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
new file mode 100644
index 0000000..24cc148
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
new file mode 100644
index 0000000..9b78d95
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
new file mode 100644
index 0000000..a20111a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
new file mode 100644
index 0000000..99e0d7a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
new file mode 100644
index 0000000..a964423
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000..23fa3fb
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
new file mode 100644
index 0000000..2c885a2
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000..18089d8
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
new file mode 100644
index 0000000..604485b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000..b9a60d7
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
new file mode 100644
index 0000000..d860d6c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000..324e4db
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
new file mode 100644
index 0000000..9eca5e5
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000..08ca208
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
new file mode 100644
index 0000000..0793933
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000..3188e7c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
new file mode 100644
index 0000000..13c1b1a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000..8cdb6a4
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
new file mode 100644
index 0000000..36ceb4e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000..6f46575
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000..a5c0f95
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000..8fba314
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000..46417de
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000..063792e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000..e428e86
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000..d76a61c
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000..6b50b82
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000..bf4c3df
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000..0effe06
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000..abfdcdb
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000..1e8e56a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
new file mode 100644
index 0000000..0f31fd5
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000..318015d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000..c6489a4
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000..2a28bcd
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000..8cb622d
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000..d68b89b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
new file mode 100644
index 0000000..a0a6bab
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
new file mode 100644
index 0000000..6691c24
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
new file mode 100644
index 0000000..c5c5e7a
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
new file mode 100644
index 0000000..3dd0834
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000..9b40ffb
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
new file mode 100644
index 0000000..e0fbcfa
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
new file mode 100644
index 0000000..dc4b355
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
new file mode 100644
index 0000000..326ef2e
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
new file mode 100644
index 0000000..2be9e46
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000..01a1c06
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
new file mode 100644
index 0000000..3a3d0de
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000..2f23136
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
new file mode 100644
index 0000000..f542bb9
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
new file mode 100644
index 0000000..dfae3c3
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
new file mode 100644
index 0000000..daff8bf
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
new file mode 100644
index 0000000..21c495b
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
new file mode 100644
index 0000000..d92bc3f
--- /dev/null
+++ b/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp b/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
new file mode 100644
index 0000000..a85659c
--- /dev/null
+++ b/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_no_pointers(char* p, size_t n);
+// void undeclare_no_pointers(char* p, size_t n);
+
+#include <memory>
+
+int main()
+{
+    char* p = new char[10];
+    std::declare_no_pointers(p, 10);
+    std::undeclare_no_pointers(p, 10);
+    delete [] p;
+}
diff --git a/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp b/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
new file mode 100644
index 0000000..3f2381f
--- /dev/null
+++ b/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_reachable(void* p);
+// template <class T> T* undeclare_reachable(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* p = new int;
+    std::declare_reachable(p);
+    assert(std::undeclare_reachable(p) == p);
+    delete p;
+}
diff --git a/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
new file mode 100644
index 0000000..868b7e9
--- /dev/null
+++ b/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::pointer_safety r = std::get_pointer_safety();
+    assert(r == std::pointer_safety::relaxed ||
+           r == std::pointer_safety::preferred ||
+           r == std::pointer_safety::strict);
+}
diff --git a/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp b/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
new file mode 100644
index 0000000..595d05c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h b/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
new file mode 100644
index 0000000..0c1eaf3
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
@@ -0,0 +1,77 @@
+#ifndef TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+#include <cassert>
+
+class test_alloc_base
+{
+protected:
+    static int time_to_throw;
+public:
+    static int throw_after;
+    static int count;
+    static int alloc_count;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::time_to_throw = 0;
+int test_alloc_base::alloc_count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(0) {++count;}
+    explicit test_allocator(int i) throw() : data_(i) {++count;}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {++count;}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {++count;}
+    ~test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            assert(data_ >= 0);
+            if (time_to_throw >= throw_after)
+                throw std::bad_alloc();
+            ++time_to_throw;
+            ++alloc_count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {assert(data_ >= 0); --alloc_count; std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+#endif
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
new file mode 100644
index 0000000..e1cdbbd
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
new file mode 100644
index 0000000..719a651
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
new file mode 100644
index 0000000..651a922
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
new file mode 100644
index 0000000..16b9aa2
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
new file mode 100644
index 0000000..3171daa
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..83b1ea2
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000..cb6ea09
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000..d15ddaf
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
new file mode 100644
index 0000000..98434a3
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
new file mode 100644
index 0000000..abf973c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
new file mode 100644
index 0000000..ca4975b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
new file mode 100644
index 0000000..232d3ca
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
new file mode 100644
index 0000000..98be66f
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
new file mode 100644
index 0000000..07620db
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
new file mode 100644
index 0000000..b43c164
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
new file mode 100644
index 0000000..4f63d81
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
new file mode 100644
index 0000000..ffab43c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
new file mode 100644
index 0000000..eb49863
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..0bbb872
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000..c4c2201
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
new file mode 100644
index 0000000..1983825
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
new file mode 100644
index 0000000..caebd4a
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
new file mode 100644
index 0000000..1e62565
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..e6f39ee
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000..40d6aa9
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
new file mode 100644
index 0000000..ac7f603
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
new file mode 100644
index 0000000..b5b217e
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
new file mode 100644
index 0000000..5cdec2b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..ef79110
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000..66a7b1b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
new file mode 100644
index 0000000..39545a3
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000..2db8fe5
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
new file mode 100644
index 0000000..c0a2f76
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000..639689c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
new file mode 100644
index 0000000..acd0884
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
new file mode 100644
index 0000000..723c9a8
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
new file mode 100644
index 0000000..ae993c2
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class CharT, class Traits, class Y>
+//   basic_ostream<CharT, Traits>&
+//   operator<<(basic_ostream<CharT, Traits>& os, shared_ptr<Y> const& p);
+
+#include <memory>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::shared_ptr<int> p(new int(3));
+    std::ostringstream os;
+    assert(os.str().empty());
+    os << p;
+    assert(!os.str().empty());
+}
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
new file mode 100644
index 0000000..1d624b2
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
new file mode 100644
index 0000000..1ee745c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
new file mode 100644
index 0000000..30a19d1
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..67244be
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
new file mode 100644
index 0000000..5511137
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
new file mode 100644
index 0000000..1cc04e0
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
new file mode 100644
index 0000000..55b745e
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
new file mode 100644
index 0000000..2855d5b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000..1184b3c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000..727b5da
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
new file mode 100644
index 0000000..3e3da51
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
new file mode 100644
index 0000000..5f73c6f
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
new file mode 100644
index 0000000..051a440
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
new file mode 100644
index 0000000..f2f436b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..02dc7e8
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
new file mode 100644
index 0000000..0e9859b
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000..1d06214
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
new file mode 100644
index 0000000..576ec0c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..15a5c1c
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000..2b49b97
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000..415ee71
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
new file mode 100644
index 0000000..9fcb909
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
new file mode 100644
index 0000000..7ee2277
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
new file mode 100644
index 0000000..59f5388
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
new file mode 100644
index 0000000..fc7e338
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
new file mode 100644
index 0000000..aa3aad7
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000..307dba5
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000..a2603af
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
new file mode 100644
index 0000000..b02f4ea
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
new file mode 100644
index 0000000..d0de482
--- /dev/null
+++ b/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
Binary files differ
diff --git a/test/utilities/memory/version.pass.cpp b/test/utilities/memory/version.pass.cpp
new file mode 100644
index 0000000..dab60f9
--- /dev/null
+++ b/test/utilities/memory/version.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.hel/integral_constant.pass.cpp b/test/utilities/meta/meta.hel/integral_constant.pass.cpp
new file mode 100644
index 0000000..f00a1f6
--- /dev/null
+++ b/test/utilities/meta/meta.hel/integral_constant.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.rel/is_base_of.pass.cpp b/test/utilities/meta/meta.rel/is_base_of.pass.cpp
new file mode 100644
index 0000000..7db7be0
--- /dev/null
+++ b/test/utilities/meta/meta.rel/is_base_of.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/utilities/meta/meta.rel/is_convertible.pass.cpp
new file mode 100644
index 0000000..379f1ee
--- /dev/null
+++ b/test/utilities/meta/meta.rel/is_convertible.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.rel/is_explicitly_convertible.pass.cpp b/test/utilities/meta/meta.rel/is_explicitly_convertible.pass.cpp
new file mode 100644
index 0000000..8a45885
--- /dev/null
+++ b/test/utilities/meta/meta.rel/is_explicitly_convertible.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.rel/is_same.pass.cpp b/test/utilities/meta/meta.rel/is_same.pass.cpp
new file mode 100644
index 0000000..0e30b7d
--- /dev/null
+++ b/test/utilities/meta/meta.rel/is_same.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp b/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
new file mode 100644
index 0000000..e2f98c3
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
new file mode 100644
index 0000000..ed2e3d8
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
new file mode 100644
index 0000000..fac7c26
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
new file mode 100644
index 0000000..dd7c158
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
new file mode 100644
index 0000000..92791ac
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
new file mode 100644
index 0000000..f857a27
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
new file mode 100644
index 0000000..ce9e6d4
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
new file mode 100644
index 0000000..cafcfa5
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
new file mode 100644
index 0000000..40e137c
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
new file mode 100644
index 0000000..36403ff
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
new file mode 100644
index 0000000..6c6a67a
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
new file mode 100644
index 0000000..c5fc1bc
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp b/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
new file mode 100644
index 0000000..e0a5381
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
new file mode 100644
index 0000000..d2914ab
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
new file mode 100644
index 0000000..ab7286e
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
new file mode 100644
index 0000000..9316521
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
new file mode 100644
index 0000000..5966d02
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
new file mode 100644
index 0000000..9df689d
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
new file mode 100644
index 0000000..06dae28
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
new file mode 100644
index 0000000..935d469
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
new file mode 100644
index 0000000..6e035ef
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
new file mode 100644
index 0000000..1f7511e
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
new file mode 100644
index 0000000..becf1e9
--- /dev/null
+++ b/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp b/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp b/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
new file mode 100644
index 0000000..4588bbb
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
new file mode 100644
index 0000000..9920732
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
new file mode 100644
index 0000000..972654b
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
new file mode 100644
index 0000000..70ba35b
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
new file mode 100644
index 0000000..ee9753f
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
new file mode 100644
index 0000000..afa6a9d
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
new file mode 100644
index 0000000..85d6bc4
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
new file mode 100644
index 0000000..77c424f
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
new file mode 100644
index 0000000..13a2577
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
new file mode 100644
index 0000000..07d38f3
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
new file mode 100644
index 0000000..0579b5a
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
new file mode 100644
index 0000000..644665e
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
new file mode 100644
index 0000000..a17e95b
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
new file mode 100644
index 0000000..a064eaa
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
new file mode 100644
index 0000000..a3ebad7
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
new file mode 100644
index 0000000..e6a30b8
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
new file mode 100644
index 0000000..35752ea
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
new file mode 100644
index 0000000..d625c53
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
new file mode 100644
index 0000000..c11d5b8
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
new file mode 100644
index 0000000..363c526
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
new file mode 100644
index 0000000..579a803
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
new file mode 100644
index 0000000..685a985
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
new file mode 100644
index 0000000..8872169
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
new file mode 100644
index 0000000..f7bef39
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
new file mode 100644
index 0000000..535a181
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
new file mode 100644
index 0000000..8abad5a
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/alignment_of.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/alignment_of.pass.cpp
new file mode 100644
index 0000000..f443969
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/alignment_of.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/extent.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/extent.pass.cpp
new file mode 100644
index 0000000..8deb5bf
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/extent.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_assign.pass.cpp
new file mode 100644
index 0000000..0c9c6fc
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_assign.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_copy_assign
+
+#include <type_traits>
+
+int main()
+{
+#error has_copy_assign not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp
new file mode 100644
index 0000000..1223249
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_copy_constructor
+
+#include <type_traits>
+
+int main()
+{
+#error has_copy_constructor not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_default_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_default_constructor.pass.cpp
new file mode 100644
index 0000000..2d48cdb
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_default_constructor.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_default_constructor
+
+#include <type_traits>
+
+int main()
+{
+#error has_default_constructor not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_move_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_move_assign.pass.cpp
new file mode 100644
index 0000000..926d3fd
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_move_assign.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_move_assign
+
+#include <type_traits>
+
+int main()
+{
+#error has_move_assign not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_move_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_move_constructor.pass.cpp
new file mode 100644
index 0000000..26b060c
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_move_constructor.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_move_constructor
+
+#include <type_traits>
+
+int main()
+{
+#error has_move_constructor not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_assign.pass.cpp
new file mode 100644
index 0000000..a08ac8f
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp
new file mode 100644
index 0000000..2561939
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_default_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_default_constructor.pass.cpp
new file mode 100644
index 0000000..6e608ee
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_default_constructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_assign.pass.cpp
new file mode 100644
index 0000000..e1ed665
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_assign.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_assign
+
+#include <type_traits>
+
+int main()
+{
+#error has_nothrow_move_assign not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_constructor.pass.cpp
new file mode 100644
index 0000000..1dfa5f1
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_move_constructor.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_constructor
+
+#include <type_traits>
+
+int main()
+{
+#error has_nothrow_move_constructor not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_assign.pass.cpp
new file mode 100644
index 0000000..9bb44c1
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_assign.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_constructor.pass.cpp
new file mode 100644
index 0000000..e142ae7
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_copy_constructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_default_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_default_constructor.pass.cpp
new file mode 100644
index 0000000..807e2e3
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_default_constructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_destructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_destructor.pass.cpp
new file mode 100644
index 0000000..cacb075
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_destructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_assign.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_assign.pass.cpp
new file mode 100644
index 0000000..9ca95a4
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_assign.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_trivial_move_assign
+
+#include <type_traits>
+
+int main()
+{
+#error has_trivial_move_assign not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_constructor.pass.cpp
new file mode 100644
index 0000000..245c589
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_trivial_move_constructor.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_trivial_move_constructor
+
+#include <type_traits>
+
+int main()
+{
+#error has_trivial_move_constructor not implemented
+}
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
new file mode 100644
index 0000000..7563806
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
new file mode 100644
index 0000000..b213049
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
new file mode 100644
index 0000000..fc3a459
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
new file mode 100644
index 0000000..0868242
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
new file mode 100644
index 0000000..b365dfb
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
new file mode 100644
index 0000000..b282715
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
new file mode 100644
index 0000000..e839e09
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
new file mode 100644
index 0000000..f554279
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
new file mode 100644
index 0000000..b933b7e
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
new file mode 100644
index 0000000..53d7882
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
new file mode 100644
index 0000000..f88d2e6
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
new file mode 100644
index 0000000..484bfaa
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
new file mode 100644
index 0000000..872b234
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
new file mode 100644
index 0000000..8d6b6b0
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
new file mode 100644
index 0000000..19b2cfa
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/rank.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/rank.pass.cpp
new file mode 100644
index 0000000..bfb96b2
--- /dev/null
+++ b/test/utilities/meta/meta.unary/meta.unary.prop/rank.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp b/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/meta/version.pass.cpp b/test/utilities/meta/version.pass.cpp
new file mode 100644
index 0000000..0286825
--- /dev/null
+++ b/test/utilities/meta/version.pass.cpp
Binary files differ
diff --git a/test/utilities/nothing_to_do.pass.cpp b/test/utilities/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
new file mode 100644
index 0000000..ca3af4b
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
new file mode 100644
index 0000000..596710f
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
new file mode 100644
index 0000000..0072415
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
new file mode 100644
index 0000000..64fa46a
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
new file mode 100644
index 0000000..c01538f
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
new file mode 100644
index 0000000..ae7d439
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
new file mode 100644
index 0000000..f5ce71b
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp b/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
new file mode 100644
index 0000000..25ea9f7
--- /dev/null
+++ b/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
new file mode 100644
index 0000000..d56357b
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
new file mode 100644
index 0000000..19014f5
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
new file mode 100644
index 0000000..c47f1c7
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
new file mode 100644
index 0000000..a650f8d
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
new file mode 100644
index 0000000..59271d3
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
new file mode 100644
index 0000000..fec10a3
--- /dev/null
+++ b/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.ratio/ratio.pass.cpp b/test/utilities/ratio/ratio.ratio/ratio.pass.cpp
new file mode 100644
index 0000000..18be924
--- /dev/null
+++ b/test/utilities/ratio/ratio.ratio/ratio.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp b/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp
new file mode 100644
index 0000000..6304b2e
--- /dev/null
+++ b/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp b/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp
new file mode 100644
index 0000000..99f352a
--- /dev/null
+++ b/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp b/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp
new file mode 100644
index 0000000..3e99b6e
--- /dev/null
+++ b/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp
Binary files differ
diff --git a/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp b/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/typedefs.pass.cpp b/test/utilities/ratio/typedefs.pass.cpp
new file mode 100644
index 0000000..68bfa8d
--- /dev/null
+++ b/test/utilities/ratio/typedefs.pass.cpp
Binary files differ
diff --git a/test/utilities/ratio/version.pass.cpp b/test/utilities/ratio/version.pass.cpp
new file mode 100644
index 0000000..c381cec
--- /dev/null
+++ b/test/utilities/ratio/version.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
new file mode 100644
index 0000000..5bc60f0
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.cons/default.pass.cpp b/test/utilities/template.bitset/bitset.cons/default.pass.cpp
new file mode 100644
index 0000000..8470ee5
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.cons/default.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
new file mode 100644
index 0000000..4af8650
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
new file mode 100644
index 0000000..6d39a62
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp
new file mode 100644
index 0000000..edfe45d
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.hash/bitset.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <bitset>
+#include <cassert>
+#include <type_traits>
+
+template <std::size_t N>
+void
+test()
+{
+    typedef std::bitset<N> T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    T bs(static_cast<unsigned long long>(N));
+    assert(h(bs) == N);
+}
+
+int main()
+{
+    test<0>();
+    test<10>();
+    test<100>();
+    test<1000>();
+}
diff --git a/test/utilities/template.bitset/bitset.members/all.pass.cpp b/test/utilities/template.bitset/bitset.members/all.pass.cpp
new file mode 100644
index 0000000..45a3cb4
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/all.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/any.pass.cpp b/test/utilities/template.bitset/bitset.members/any.pass.cpp
new file mode 100644
index 0000000..ede38cd
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/any.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/count.pass.cpp b/test/utilities/template.bitset/bitset.members/count.pass.cpp
new file mode 100644
index 0000000..fbb1cff
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/count.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp b/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
new file mode 100644
index 0000000..bb180d7
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
new file mode 100644
index 0000000..8985e37
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/index.pass.cpp b/test/utilities/template.bitset/bitset.members/index.pass.cpp
new file mode 100644
index 0000000..f59e474
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/index.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/index_const.pass.cpp b/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
new file mode 100644
index 0000000..0b74f82
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp b/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
new file mode 100644
index 0000000..e6017e0
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
new file mode 100644
index 0000000..11da5ad
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/none.pass.cpp b/test/utilities/template.bitset/bitset.members/none.pass.cpp
new file mode 100644
index 0000000..a695285
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/none.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/not_all.pass.cpp b/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
new file mode 100644
index 0000000..4b5bcbd
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
new file mode 100644
index 0000000..940ef95
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
new file mode 100644
index 0000000..8e2e5e5
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
new file mode 100644
index 0000000..70300d6
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
new file mode 100644
index 0000000..00724f4
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp b/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
new file mode 100644
index 0000000..5bde1d3
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
new file mode 100644
index 0000000..631030a
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp b/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
new file mode 100644
index 0000000..372d32a
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp b/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
new file mode 100644
index 0000000..724c39e
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/set_all.pass.cpp b/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
new file mode 100644
index 0000000..a26a47d
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/set_one.pass.cpp b/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
new file mode 100644
index 0000000..d01a70d
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/size.pass.cpp b/test/utilities/template.bitset/bitset.members/size.pass.cpp
new file mode 100644
index 0000000..5641b1d
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/size.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/test.pass.cpp b/test/utilities/template.bitset/bitset.members/test.pass.cpp
new file mode 100644
index 0000000..2f29037
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/test.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/to_string.pass.cpp b/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
new file mode 100644
index 0000000..c1c11f1
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
new file mode 100644
index 0000000..c975c18
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
new file mode 100644
index 0000000..954a5b5
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp b/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp
new file mode 100644
index 0000000..f525057
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp b/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp
new file mode 100644
index 0000000..7f6479e
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp b/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp
new file mode 100644
index 0000000..a55b61b
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp b/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
new file mode 100644
index 0000000..2a37097
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp b/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
new file mode 100644
index 0000000..1bd1b85
--- /dev/null
+++ b/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/includes.pass.cpp b/test/utilities/template.bitset/includes.pass.cpp
new file mode 100644
index 0000000..2a6e444
--- /dev/null
+++ b/test/utilities/template.bitset/includes.pass.cpp
Binary files differ
diff --git a/test/utilities/template.bitset/version.pass.cpp b/test/utilities/template.bitset/version.pass.cpp
new file mode 100644
index 0000000..af19027
--- /dev/null
+++ b/test/utilities/template.bitset/version.pass.cpp
Binary files differ
diff --git a/test/utilities/time/clock.h b/test/utilities/time/clock.h
new file mode 100644
index 0000000..d5f4c02
--- /dev/null
+++ b/test/utilities/time/clock.h
@@ -0,0 +1,17 @@
+#ifndef CLOCK_H
+#define CLOCK_H
+
+#include <chrono>
+
+class Clock
+{
+    typedef std::chrono::nanoseconds                 duration;
+    typedef duration::rep                            rep;
+    typedef duration::period                         period;
+    typedef std::chrono::time_point<Clock, duration> time_point;
+    static const bool is_monotonic =                 false;
+
+    static time_point now();
+};
+
+#endif
diff --git a/test/utilities/time/hours.pass.cpp b/test/utilities/time/hours.pass.cpp
new file mode 100644
index 0000000..dd73a3f
--- /dev/null
+++ b/test/utilities/time/hours.pass.cpp
Binary files differ
diff --git a/test/utilities/time/microseconds.pass.cpp b/test/utilities/time/microseconds.pass.cpp
new file mode 100644
index 0000000..dc1f83d
--- /dev/null
+++ b/test/utilities/time/microseconds.pass.cpp
Binary files differ
diff --git a/test/utilities/time/milliseconds.pass.cpp b/test/utilities/time/milliseconds.pass.cpp
new file mode 100644
index 0000000..d7f2676
--- /dev/null
+++ b/test/utilities/time/milliseconds.pass.cpp
Binary files differ
diff --git a/test/utilities/time/minutes.pass.cpp b/test/utilities/time/minutes.pass.cpp
new file mode 100644
index 0000000..ad4810f
--- /dev/null
+++ b/test/utilities/time/minutes.pass.cpp
Binary files differ
diff --git a/test/utilities/time/nanoseconds.pass.cpp b/test/utilities/time/nanoseconds.pass.cpp
new file mode 100644
index 0000000..57e8df4
--- /dev/null
+++ b/test/utilities/time/nanoseconds.pass.cpp
Binary files differ
diff --git a/test/utilities/time/rep.h b/test/utilities/time/rep.h
new file mode 100644
index 0000000..fa949fe
--- /dev/null
+++ b/test/utilities/time/rep.h
@@ -0,0 +1,18 @@
+#ifndef REP_H
+#define REP_H
+
+class Rep
+{
+    int data_;
+public:
+    Rep() : data_(-1) {}
+    explicit Rep(int i) : data_(i) {}
+
+    bool operator==(int i) const {return data_ == i;}
+    bool operator==(const Rep& r) const {return data_ == r.data_;}
+
+    Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
+    Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
+};
+
+#endif
diff --git a/test/utilities/time/seconds.pass.cpp b/test/utilities/time/seconds.pass.cpp
new file mode 100644
index 0000000..e5e0118
--- /dev/null
+++ b/test/utilities/time/seconds.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp b/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/nothing_to_do.pass.cpp b/test/utilities/time/time.clock/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9234826
--- /dev/null
+++ b/test/utilities/time/time.clock/nothing_to_do.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
new file mode 100644
index 0000000..1263336
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp b/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp
new file mode 100644
index 0000000..a1adf3d
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.monotonic/consistency.pass.cpp b/test/utilities/time/time.clock/time.clock.monotonic/consistency.pass.cpp
new file mode 100644
index 0000000..4e2f86a
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.monotonic/consistency.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.monotonic/now.pass.cpp b/test/utilities/time/time.clock/time.clock.monotonic/now.pass.cpp
new file mode 100644
index 0000000..dd8a4c8
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.monotonic/now.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
new file mode 100644
index 0000000..c210b58
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp b/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
new file mode 100644
index 0000000..36f8657
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.system/now.pass.cpp b/test/utilities/time/time.clock/time.clock.system/now.pass.cpp
new file mode 100644
index 0000000..1c31f1a
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.system/now.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp b/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
new file mode 100644
index 0000000..02112fc
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp b/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
new file mode 100644
index 0000000..a04fe02
--- /dev/null
+++ b/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/default_ratio.pass.cpp b/test/utilities/time/time.duration/default_ratio.pass.cpp
new file mode 100644
index 0000000..5294c69
--- /dev/null
+++ b/test/utilities/time/time.duration/default_ratio.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/duration.fail.cpp b/test/utilities/time/time.duration/duration.fail.cpp
new file mode 100644
index 0000000..e288838
--- /dev/null
+++ b/test/utilities/time/time.duration/duration.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/positive_num.fail.cpp b/test/utilities/time/time.duration/positive_num.fail.cpp
new file mode 100644
index 0000000..26e8c0f
--- /dev/null
+++ b/test/utilities/time/time.duration/positive_num.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/ratio.fail.cpp b/test/utilities/time/time.duration/ratio.fail.cpp
new file mode 100644
index 0000000..adcc21e
--- /dev/null
+++ b/test/utilities/time/time.duration/ratio.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
new file mode 100644
index 0000000..0be2410
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
new file mode 100644
index 0000000..124ec39
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
new file mode 100644
index 0000000..2d6f997
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
new file mode 100644
index 0000000..84c6fad
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
new file mode 100644
index 0000000..5423d6f
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
new file mode 100644
index 0000000..9fee8c3
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
new file mode 100644
index 0000000..4df2fcd
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
new file mode 100644
index 0000000..cb798a4
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
new file mode 100644
index 0000000..5fce07a
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
new file mode 100644
index 0000000..912b43e
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
new file mode 100644
index 0000000..b8a7930
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp b/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
new file mode 100644
index 0000000..1cd8925
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp b/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
new file mode 100644
index 0000000..a972949
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp b/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
new file mode 100644
index 0000000..e9f2a48
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp b/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
new file mode 100644
index 0000000..c7d2269
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp b/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
new file mode 100644
index 0000000..f477f42
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
new file mode 100644
index 0000000..318f336
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp b/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
new file mode 100644
index 0000000..42b02ac
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp b/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
new file mode 100644
index 0000000..dc5bde4
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
new file mode 100644
index 0000000..0539ab0
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
new file mode 100644
index 0000000..43f026d
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
new file mode 100644
index 0000000..1dd7c5e
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
new file mode 100644
index 0000000..eea99f5
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp b/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
new file mode 100644
index 0000000..435091e
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp b/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
new file mode 100644
index 0000000..8fa3d03
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp b/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
new file mode 100644
index 0000000..2e63a34
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp b/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
new file mode 100644
index 0000000..10b44d0
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
new file mode 100644
index 0000000..4979b15
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
new file mode 100644
index 0000000..b349cf5
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
new file mode 100644
index 0000000..181fc6a
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
new file mode 100644
index 0000000..2ce8069
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
new file mode 100644
index 0000000..a010c57
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
new file mode 100644
index 0000000..5b428e3
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
new file mode 100644
index 0000000..c7b6357
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
Binary files differ
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
new file mode 100644
index 0000000..98c4eb7
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator%(const duration<Rep1, Period>& d, const Rep2& s)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::nanoseconds ns(15);
+    ns = ns % 6;
+    assert(ns.count() == 3);
+}
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
new file mode 100644
index 0000000..4240134
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::nanoseconds ns(3);
+    ns = ns * 5;
+    assert(ns.count() == 15);
+    ns = 6 * ns;
+    assert(ns.count() == 90);
+}
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
new file mode 100644
index 0000000..45d6a3e
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d;
+    d = d * 5;
+}
diff --git a/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
new file mode 100644
index 0000000..e2134fb
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2> 
+//   duration<typename common_type<Rep1, Rep2>::type, Period> 
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d;
+    d = 5 * d;
+}
diff --git a/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp b/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/time/time.duration/time.duration.special/max.pass.cpp b/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
new file mode 100644
index 0000000..2cedbf8
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration max();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    typedef typename D::rep Rep;
+    Rep max_rep = std::chrono::duration_values<Rep>::max();
+    assert(D::max().count() == max_rep);
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/test/utilities/time/time.duration/time.duration.special/min.pass.cpp b/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
new file mode 100644
index 0000000..827bd06
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration min();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    typedef typename D::rep Rep;
+    Rep min_rep = std::chrono::duration_values<Rep>::min();
+    assert(D::min().count() == min_rep);
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp b/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
new file mode 100644
index 0000000..1ee11bd
--- /dev/null
+++ b/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration zero();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    typedef typename D::rep Rep;
+    Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+    assert(D::zero().count() == zero_rep);
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/test/utilities/time/time.duration/types.pass.cpp b/test/utilities/time/time.duration/types.pass.cpp
new file mode 100644
index 0000000..ab42317
--- /dev/null
+++ b/test/utilities/time/time.duration/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Test nested types
+
+// typedef Rep rep; 
+// typedef Period period; 
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+    typedef std::chrono::duration<long, std::ratio<3, 2> > D;
+    static_assert((std::is_same<D::rep, long>::value), "");
+    static_assert((std::is_same<D::period, std::ratio<3, 2> >::value), "");
+}
diff --git a/test/utilities/time/time.point/default_duration.pass.cpp b/test/utilities/time/time.point/default_duration.pass.cpp
new file mode 100644
index 0000000..d4ac693
--- /dev/null
+++ b/test/utilities/time/time.point/default_duration.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Test default template arg:
+
+// template <class Clock, class Duration = typename Clock::duration> 
+//   class time_point;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::chrono::system_clock::duration,
+                   std::chrono::time_point<std::chrono::system_clock>::duration>::value), "");
+}
diff --git a/test/utilities/time/time.point/duration.fail.cpp b/test/utilities/time/time.point/duration.fail.cpp
new file mode 100644
index 0000000..5c2b717
--- /dev/null
+++ b/test/utilities/time/time.point/duration.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Duration shall be an instance of duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::time_point<std::chrono::system_clock, int> T;
+    T t;
+}
diff --git a/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
new file mode 100644
index 0000000..8eb2a41
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.arithmetic/op_+=.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator+=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    t += Duration(2);
+    assert(t.time_since_epoch() == Duration(5));
+}
diff --git a/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
new file mode 100644
index 0000000..0c28e7d
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.arithmetic/op_-=.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator-=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    t -= Duration(2);
+    assert(t.time_since_epoch() == Duration(1));
+}
diff --git a/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
new file mode 100644
index 0000000..41544c9
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cast/time_point_cast.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration> 
+//   time_point<Clock, ToDuration>
+//   time_point_cast(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+    typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+    FromTimePoint f(df);
+    ToTimePoint t(d);
+    typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
+    static_assert((std::is_same<R, ToTimePoint>::value), "");
+    assert(std::chrono::time_point_cast<ToDuration>(f) == t);
+}
+
+int main()
+{
+    test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+    test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+    test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+    test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+    test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+    test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+    test(std::chrono::milliseconds(7265000),
+         std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+    test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+         std::chrono::duration<int, std::ratio<3, 5> >(10));
+}
diff --git a/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp b/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
new file mode 100644
index 0000000..af0f378
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration> 
+//   time_point<Clock, ToDuration>
+//   time_point_cast(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, std::chrono::milliseconds> FromTimePoint;
+    typedef std::chrono::time_point<Clock, std::chrono::minutes> ToTimePoint;
+    std::chrono::time_point_cast<ToTimePoint>(FromTimePoint(std::chrono::milliseconds(3)));
+}
diff --git a/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp b/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
new file mode 100644
index 0000000..92502c1
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock1;
+    typedef Clock                     Clock2;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock1, Duration1> T1;
+    typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    t1 == t2;
+}
diff --git a/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp b/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
new file mode 100644
index 0000000..f49cd32
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock, Duration1> T1;
+    typedef std::chrono::time_point<Clock, Duration2> T2;
+
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(3));
+    assert( (t1 == t2));
+    assert(!(t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(4));
+    assert(!(t1 == t2));
+    assert( (t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    assert( (t1 == t2));
+    assert(!(t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3001));
+    assert(!(t1 == t2));
+    assert( (t1 != t2));
+    }
+}
diff --git a/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp b/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
new file mode 100644
index 0000000..e2c26c2
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.comparisons/op_less.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock1;
+    typedef Clock                     Clock2;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock1, Duration1> T1;
+    typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    t1 < t2;
+}
diff --git a/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp b/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
new file mode 100644
index 0000000..cbb2f10
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2> 
+//   bool
+//   operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock, Duration1> T1;
+    typedef std::chrono::time_point<Clock, Duration2> T2;
+
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(3));
+    assert(!(t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert( (t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(4));
+    assert( (t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    assert(!(t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert( (t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3001));
+    assert( (t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >= t2));
+    }
+}
diff --git a/test/utilities/time/time.point/time.point.cons/convert.fail.cpp b/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
new file mode 100644
index 0000000..88cef15
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2> 
+//   time_point(const time_point<clock, Duration2>& t);
+
+// Duration2 shall be implicitly convertible to duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    std::chrono::time_point<Clock, Duration1> t1 = t2;
+    }
+}
diff --git a/test/utilities/time/time.point/time.point.cons/convert.pass.cpp b/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
new file mode 100644
index 0000000..bb8587f
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2> 
+//   time_point(const time_point<clock, Duration2>& t);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::microseconds Duration1;
+    typedef std::chrono::milliseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    std::chrono::time_point<Clock, Duration1> t1 = t2;
+    assert(t1.time_since_epoch() == Duration1(3000));
+    }
+}
diff --git a/test/utilities/time/time.point/time.point.cons/default.pass.cpp b/test/utilities/time/time.point/time.point.cons/default.pass.cpp
new file mode 100644
index 0000000..736a0ca
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cons/default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::duration<Rep, std::milli> Duration;
+    std::chrono::time_point<Clock, Duration> t;
+    assert(t.time_since_epoch() == Duration::zero());
+}
diff --git a/test/utilities/time/time.point/time.point.cons/duration.fail.cpp b/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
new file mode 100644
index 0000000..4a742c8
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+// test for explicit
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t = Duration(3);
+}
diff --git a/test/utilities/time/time.point/time.point.cons/duration.pass.cpp b/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
new file mode 100644
index 0000000..3c53686
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    {
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    assert(t.time_since_epoch() == Duration(3));
+    }
+    {
+    std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+    assert(t.time_since_epoch() == Duration(3000));
+    }
+}
diff --git a/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp b/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
new file mode 100644
index 0000000..016391e
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2> 
+//   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 
+//   operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Clock, class Duration2> 
+//   time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> 
+//   operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+    assert(t2.time_since_epoch() == Duration2(3005));
+    t2 = Duration2(6) + t1;
+    assert(t2.time_since_epoch() == Duration2(3006));
+}
diff --git a/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
new file mode 100644
index 0000000..98cfa6c
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2> 
+//   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 
+//   operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+    assert(t2.time_since_epoch() == Duration2(2995));
+}
diff --git a/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp b/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
new file mode 100644
index 0000000..76fb101
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2> 
+//   typename common_type<Duration1, Duration2>::type 
+//   operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+    assert((t1 - t2) == Duration2(2995));
+}
diff --git a/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp b/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/time/time.point/time.point.special/max.pass.cpp b/test/utilities/time/time.point/time.point.special/max.pass.cpp
new file mode 100644
index 0000000..65d9598
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.special/max.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point max();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    typedef std::chrono::time_point<Clock, Duration> TP;
+    assert(TP::max() == TP(Duration::max()));
+}
diff --git a/test/utilities/time/time.point/time.point.special/min.pass.cpp b/test/utilities/time/time.point/time.point.special/min.pass.cpp
new file mode 100644
index 0000000..e411f5b
--- /dev/null
+++ b/test/utilities/time/time.point/time.point.special/min.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point min();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    typedef std::chrono::time_point<Clock, Duration> TP;
+    assert(TP::min() == TP(Duration::min()));
+}
diff --git a/test/utilities/time/time.traits/nothing_to_do.pass.cpp b/test/utilities/time/time.traits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/time/time.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp b/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
new file mode 100644
index 0000000..2d18f4a
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::max
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::max() ==
+           std::numeric_limits<int>::max());
+    assert(std::chrono::duration_values<double>::max() ==
+           std::numeric_limits<double>::max());
+    assert(std::chrono::duration_values<Rep>::max() ==
+           std::numeric_limits<Rep>::max());
+}
diff --git a/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp b/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
new file mode 100644
index 0000000..73c4baa
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::min
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::min() ==
+           std::numeric_limits<int>::lowest());
+    assert(std::chrono::duration_values<double>::min() ==
+           std::numeric_limits<double>::lowest());
+    assert(std::chrono::duration_values<Rep>::min() ==
+           std::numeric_limits<Rep>::lowest());
+}
diff --git a/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp b/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
new file mode 100644
index 0000000..6651841
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::zero
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::zero() == 0);
+    assert(std::chrono::duration_values<Rep>::zero() == 0);
+}
diff --git a/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
new file mode 100644
index 0000000..466e09d
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// treat_as_floating_point
+
+#include <chrono>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::is_floating_point<T>,
+                                   std::chrono::treat_as_floating_point<T> >::value), "");
+}
+
+struct A {};
+
+int main()
+{
+    test<int>();
+    test<unsigned>();
+    test<char>();
+    test<bool>();
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<A>();
+}
diff --git a/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp b/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
new file mode 100644
index 0000000..1d76bfc
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Rep1, class Period1, class Rep2, class Period2> 
+// struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
+// {
+//     typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type; 
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+    typedef typename std::common_type<D1, D2>::type Dc;
+    static_assert((std::is_same<Dc, De>::value), "");
+}
+
+int main()
+{
+    test<std::chrono::duration<int, std::ratio<1, 100> >,
+         std::chrono::duration<long, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<long, std::ratio<1, 100> >,
+         std::chrono::duration<int, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<char, std::ratio<1, 30> >,
+         std::chrono::duration<short, std::ratio<1, 1000> >,
+         std::chrono::duration<int, std::ratio<1, 3000> > >();
+    test<std::chrono::duration<double, std::ratio<21, 1> >,
+         std::chrono::duration<short, std::ratio<15, 1> >,
+         std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp b/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
new file mode 100644
index 0000000..b3e95c4
--- /dev/null
+++ b/test/utilities/time/time.traits/time.traits.specializations/time_point.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Clock, class Duration1, class Duration2> 
+// struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
+// { 
+//     typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type; 
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+    typedef std::chrono::system_clock C;
+    typedef std::chrono::time_point<C, D1> T1;
+    typedef std::chrono::time_point<C, D2> T2;
+    typedef std::chrono::time_point<C, De> Te;
+    typedef typename std::common_type<T1, T2>::type Tc;
+    static_assert((std::is_same<Tc, Te>::value), "");
+}
+
+int main()
+{
+    test<std::chrono::duration<int, std::ratio<1, 100> >,
+         std::chrono::duration<long, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<long, std::ratio<1, 100> >,
+         std::chrono::duration<int, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<char, std::ratio<1, 30> >,
+         std::chrono::duration<short, std::ratio<1, 1000> >,
+         std::chrono::duration<int, std::ratio<1, 3000> > >();
+    test<std::chrono::duration<double, std::ratio<21, 1> >,
+         std::chrono::duration<short, std::ratio<15, 1> >,
+         std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/test/utilities/time/version.pass.cpp b/test/utilities/time/version.pass.cpp
new file mode 100644
index 0000000..b25adae
--- /dev/null
+++ b/test/utilities/time/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp b/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/tuple/tuple.tuple/DefaultOnly.h b/test/utilities/tuple/tuple.tuple/DefaultOnly.h
new file mode 100644
index 0000000..d40e9c1
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/DefaultOnly.h
@@ -0,0 +1,26 @@
+#ifndef DEFAULTONLY_H
+#define DEFAULTONLY_H
+
+#include <cassert>
+
+class DefaultOnly
+{
+    int data_;
+
+    DefaultOnly(const DefaultOnly&);
+    DefaultOnly& operator=(const DefaultOnly&);
+public:
+    static int count;
+
+    DefaultOnly() : data_(-1) {++count;}
+    ~DefaultOnly() {data_ = 0; --count;}
+
+    friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ < y.data_;}
+};
+
+int DefaultOnly::count = 0;
+
+#endif
diff --git a/test/utilities/tuple/tuple.tuple/MoveOnly.h b/test/utilities/tuple/tuple.tuple/MoveOnly.h
new file mode 100644
index 0000000..b7d62b7
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/MoveOnly.h
@@ -0,0 +1,41 @@
+#ifndef MOVEONLY_H
+#define MOVEONLY_H
+
+#ifdef _LIBCPP_MOVE
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+
+    bool operator==(const MoveOnly& x) const {return data_ == x.data_;}    
+    bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}    
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+    : public std::unary_function<MoveOnly, std::size_t>
+{
+    std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif
+
+#endif
diff --git a/test/utilities/tuple/tuple.tuple/alloc_first.h b/test/utilities/tuple/tuple.tuple/alloc_first.h
new file mode 100644
index 0000000..2b2183a
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/alloc_first.h
@@ -0,0 +1,49 @@
+#ifndef ALLOC_FIRST_H
+#define ALLOC_FIRST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_first
+{
+    static bool allocator_constructed;
+
+    typedef A1<int> allocator_type;
+
+    int data_;
+
+    alloc_first() : data_(0) {}
+    alloc_first(int d) : data_(d) {}
+    alloc_first(std::allocator_arg_t, const A1<int>& a)
+        : data_(0)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_first(std::allocator_arg_t, const A1<int>& a, int d)
+        : data_(d)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)
+        : data_(d.data_)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    ~alloc_first() {data_ = -1;}
+
+    friend bool operator==(const alloc_first& x, const alloc_first& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const alloc_first& x, const alloc_first& y)
+        {return x.data_ < y.data_;}
+};
+
+bool alloc_first::allocator_constructed = false;
+
+#endif
diff --git a/test/utilities/tuple/tuple.tuple/alloc_last.h b/test/utilities/tuple/tuple.tuple/alloc_last.h
new file mode 100644
index 0000000..7601c9d
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/alloc_last.h
@@ -0,0 +1,49 @@
+#ifndef ALLOC_LAST_H
+#define ALLOC_LAST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_last
+{
+    static bool allocator_constructed;
+
+    typedef A1<int> allocator_type;
+
+    int data_;
+
+    alloc_last() : data_(0) {}
+    alloc_last(int d) : data_(d) {}
+    alloc_last(const A1<int>& a)
+        : data_(0)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_last(int d, const A1<int>& a)
+        : data_(d)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_last(const alloc_last& d, const A1<int>& a)
+        : data_(d.data_)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    ~alloc_last() {data_ = -1;}
+
+    friend bool operator==(const alloc_last& x, const alloc_last& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const alloc_last& x, const alloc_last& y)
+        {return x.data_ < y.data_;}
+};
+
+bool alloc_last::allocator_constructed = false;
+
+#endif
diff --git a/test/utilities/tuple/tuple.tuple/allocators.h b/test/utilities/tuple/tuple.tuple/allocators.h
new file mode 100644
index 0000000..7075f85
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/allocators.h
@@ -0,0 +1,176 @@
+#ifndef ALLOCATORS_H
+#define ALLOCATORS_H
+
+#include <type_traits>
+#include <utility>
+
+#ifdef _LIBCPP_MOVE
+
+template <class T>
+class A1
+{
+    int id_;
+public:
+    explicit A1(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+    static std::pair<T*, std::size_t> deallocate_called;
+
+    A1(const A1& a) : id_(a.id()) {copy_called = true;}
+    A1(A1&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U>
+        A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
+    template <class U>
+        A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
+
+    T* allocate(std::size_t n)
+    {
+        allocate_called = true;
+        return (T*)n;
+    }
+
+    void deallocate(T* p, std::size_t n)
+    {
+        deallocate_called = std::pair<T*, std::size_t>(p, n);
+    }
+
+    std::size_t max_size() const {return id_;}
+};
+
+template <class T> bool A1<T>::copy_called = false;
+template <class T> bool A1<T>::move_called = false;
+template <class T> bool A1<T>::allocate_called = false;
+template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
+
+template <class T, class U>
+inline
+bool operator==(const A1<T>& x, const A1<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A1<T>& x, const A1<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A2
+{
+    int id_;
+public:
+    explicit A2(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef unsigned size_type;
+    typedef int difference_type;
+
+    typedef std::true_type propagate_on_container_move_assignment;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+
+    A2(const A2& a) : id_(a.id()) {copy_called = true;}
+    A2(A2&& a) : id_(a.id())      {move_called = true;}
+
+    T* allocate(std::size_t n, const void* hint)
+    {
+        allocate_called = true;
+        return (T*)hint;
+    }
+};
+
+template <class T> bool A2<T>::copy_called = false;
+template <class T> bool A2<T>::move_called = false;
+template <class T> bool A2<T>::allocate_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A2<T>& x, const A2<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A2<T>& x, const A2<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A3
+{
+    int id_;
+public:
+    explicit A3(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool constructed;
+    static bool destroy_called;
+
+    A3(const A3& a) : id_(a.id()) {copy_called = true;}
+    A3(A3&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U, class ...Args>
+    void construct(U* p, Args&& ...args)
+    {
+        ::new (p) U(std::forward<Args>(args)...);
+        constructed = true;
+    }
+
+    template <class U>
+    void destroy(U* p)
+    {
+        p->~U();
+        destroy_called = true;
+    }
+
+    A3 select_on_container_copy_construction() const {return A3(-1);}
+};
+
+
+
+template <class T> bool A3<T>::copy_called = false;
+template <class T> bool A3<T>::move_called = false;
+template <class T> bool A3<T>::constructed = false;
+template <class T> bool A3<T>::destroy_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A3<T>& x, const A3<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A3<T>& x, const A3<U>& y)
+{
+    return !(x == y);
+}
+
+#endif
+
+#endif
diff --git a/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp b/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
new file mode 100644
index 0000000..53783cc
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/empty_member.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// This is not a portable test
+
+#include <tuple>
+
+struct A {};
+
+struct B {};
+
+int main()
+{
+    {
+        typedef std::tuple<int, A> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, int> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, int, B> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, B, int> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<int, A, B> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
new file mode 100644
index 0000000..b1c9859
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+//   tuple& operator=(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<double, char> T0;
+        typedef std::tuple<int, short> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == short('a'));
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
new file mode 100644
index 0000000..b47d4b6
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   tuple& operator=(const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i = 0) : id_(i) {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i = 0) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        D d2(2);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d2);
+        T1 t1(1.5, 'b', d);
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
new file mode 100644
index 0000000..7c59907
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   tuple& operator=(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i= 0) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        D d2(2);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d2);
+        T1 t1(1.5, 'b', d);
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+    {
+        typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
new file mode 100644
index 0000000..39a6a1a
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(2));
+        T t;
+        t = t0;
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
new file mode 100644
index 0000000..70604bf
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t;
+        t = t0;
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<int, char> T;
+        T t0(2, 'a');
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+    }
+    {
+        typedef std::tuple<int, char, std::string> T;
+        T t0(2, 'a', "some text");
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+        assert(std::get<2>(t) == "some text");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
new file mode 100644
index 0000000..423e9bf
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t;
+        t = std::move(t0);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
new file mode 100644
index 0000000..886efda
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+//   tuple& operator=(pair<U1, U2>&& u);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i = 0) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+
+int main()
+{
+    {
+        typedef std::pair<double, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
new file mode 100644
index 0000000..65c2fa6
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   explicit tuple(UTypes&&... u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t = MoveOnly(0);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
new file mode 100644
index 0000000..43416af
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   explicit tuple(UTypes&&... u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t(MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t(MoveOnly(0), MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+                                                   MoveOnly(1),
+                                                   MoveOnly(2));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+    // extensions
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+                                                   MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == MoveOnly());
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == MoveOnly());
+        assert(std::get<2>(t) == MoveOnly());
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
new file mode 100644
index 0000000..e9ad452
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a);
+
+#include <tuple>
+#include <cassert>
+
+#include "../DefaultOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<> t(std::allocator_arg, A1<int>());
+    }
+    {
+        std::tuple<int> t(std::allocator_arg, A1<int>());
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
+        assert(std::get<0>(t) == DefaultOnly());
+    }
+    {
+        assert(!alloc_first::allocator_constructed);
+        std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == alloc_first());
+    }
+    {
+        assert(!alloc_last::allocator_constructed);
+        std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == alloc_last());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+                                                           A1<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+                                                           A2<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(!alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+        assert(!alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last());
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
new file mode 100644
index 0000000..c3e09b9
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+                                         MoveOnly(0), MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 
+                                                   MoveOnly(0),
+                                                   1, 2);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A1<int>(5), 1, 2, 3);
+        assert(std::get<0>(t) == 1);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+    // extensions
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 
+                                                   0, 1);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == MoveOnly());
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(), 
+                                                   0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == MoveOnly());
+        assert(std::get<2>(t) == MoveOnly());
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
new file mode 100644
index 0000000..d32e62d
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, const Types&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
+        assert(std::get<0>(t) == 3);
+    }
+    {
+        assert(!alloc_first::allocator_constructed);
+        std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == alloc_first(3));
+    }
+    {
+        assert(!alloc_last::allocator_constructed);
+        std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == alloc_last(3));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
+                                       10, alloc_first(15));
+        assert(std::get<0>(t) == 10);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(15));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A1<int>(5), 1, alloc_first(2),
+                                                   alloc_last(3));
+        assert(std::get<0>(t) == 1);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A2<int>(5), 1, alloc_first(2),
+                                                   alloc_last(3));
+        assert(std::get<0>(t) == 1);
+        assert(!alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(!alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
new file mode 100644
index 0000000..00ee35a
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+//   tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::pair<double, int> T0;
+        typedef std::tuple<int, double> T1;
+        T0 t0(2, 3);
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::pair<int, int> T0;
+        typedef std::tuple<alloc_first, double> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::pair<int, int> T0;
+        typedef std::tuple<alloc_first, alloc_last> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
new file mode 100644
index 0000000..4b5310a
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1(std::allocator_arg, A1<int>(), t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<int> T0;
+        typedef std::tuple<alloc_first> T1;
+        T0 t0(2);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<int, int> T0;
+        typedef std::tuple<alloc_first, alloc_last> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::tuple<double, int, int> T0;
+        typedef std::tuple<int, alloc_first, alloc_last> T1;
+        T0 t0(1.5, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 1);
+        assert(std::get<1>(t1) == 2);
+        assert(std::get<2>(t1) == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
new file mode 100644
index 0000000..2c3c5dc
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<int> T0;
+        typedef std::tuple<alloc_first> T1;
+        T0 t0(2);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<std::unique_ptr<D>> T0;
+        typedef std::tuple<std::unique_ptr<B>> T1;
+        T0 t0(std::unique_ptr<D>(new D(3)));
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(std::get<0>(t1)->id_ == 3);
+    }
+    {
+        typedef std::tuple<int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+    {
+        typedef std::tuple<int, int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_last, alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(1, 2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 1);
+        assert(std::get<1>(t1) == 2);
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
new file mode 100644
index 0000000..2bb2bc0
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, const tuple&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t(std::allocator_arg, A1<int>(), t0);
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t(std::allocator_arg, A1<int>(), t0);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_first> T;
+        T t0(2);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_last> T;
+        T t0(2);
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_first, alloc_last> T;
+        T t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 3);
+    }
+    {
+        typedef std::tuple<int, alloc_first, alloc_last> T;
+        T t0(1, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
new file mode 100644
index 0000000..938230b
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, tuple&&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t(std::allocator_arg, A1<int>(), std::move(t0));
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t(std::allocator_arg, A1<int>(), std::move(t0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<alloc_first> T;
+        T t0(1);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+    }
+    {
+        typedef std::tuple<alloc_last> T;
+        T t0(1);
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, alloc_first> T;
+        T t0(0 ,1);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
+        T t0(1, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
new file mode 100644
index 0000000..d04c946
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+//   tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+
+int main()
+{
+    {
+        typedef std::pair<int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
new file mode 100644
index 0000000..93f28d5
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int> t = 2;
+        assert(std::get<0>(t) == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
new file mode 100644
index 0000000..b2a945d
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int> t(2);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        std::tuple<int, char*> t(2, 0);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+    }
+    {
+        std::tuple<int, char*> t(2, nullptr);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+    }
+    {
+        std::tuple<int, char*, std::string> t(2, nullptr, "text");
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "text");
+    }
+    // extensions
+    {
+        std::tuple<int, char*, std::string> t(2);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string> t(2, nullptr);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string, double> t(2, nullptr, "text");
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "text");
+        assert(std::get<3>(t) == 0.0);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
new file mode 100644
index 0000000..864896e
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int, char*, std::string, double&> t(2, nullptr, "text");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
new file mode 100644
index 0000000..91b14f5
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<double, char> T0;
+        typedef std::tuple<int, short> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == short('a'));
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
new file mode 100644
index 0000000..4672b9e
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d);
+        T1 t1 = t0;
+        d.id_ = 2;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
new file mode 100644
index 0000000..4ab026d
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d);
+        T1 t1 = std::move(t0);
+        d.id_ = 2;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+    {
+        typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
new file mode 100644
index 0000000..6aff227
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(2));
+        T t = t0;
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..1c637f3
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t = t0;
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<int, char> T;
+        T t0(2, 'a');
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+    }
+    {
+        typedef std::tuple<int, char, std::string> T;
+        T t0(2, 'a', "some text");
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+        assert(std::get<2>(t) == "some text");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
new file mode 100644
index 0000000..0321fc1
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// constexpr tuple();
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#include "../DefaultOnly.h"
+
+int main()
+{
+    {
+        std::tuple<> t;
+    }
+    {
+        std::tuple<int> t;
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<int, char*> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+    }
+    {
+        std::tuple<int, char*, std::string> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string, DefaultOnly> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+        assert(std::get<3>(t) == DefaultOnly());
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
new file mode 100644
index 0000000..dd4867b
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t = std::move(t0);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
new file mode 100644
index 0000000..c6f8e71
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(pair<U1, U2>&& u);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+
+int main()
+{
+    {
+        typedef std::pair<double, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
new file mode 100644
index 0000000..86fa52f
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+//   tuple<VTypes...> make_tuple(Types&&... t);
+
+#include <tuple>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        float j = 0;
+        std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
+                                                          std::ref(j));
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 0);
+        assert(std::get<2>(t) == 0);
+        i = 2;
+        j = 3.5;
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3.5);
+        std::get<1>(t) = 0;
+        std::get<2>(t) = 0;
+        assert(i == 0);
+        assert(j == 0);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
new file mode 100644
index 0000000..a232c9a
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+//   tuple<Types&...> tie(Types&... t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        std::string s;
+        std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
+        assert(i == 42);
+        assert(s == "C++");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
new file mode 100644
index 0000000..27e25d2
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... TTypes, class... UTypes>
+//   tuple<TTypes..., UTypes...>
+//   tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template <class... TTypes, class... UTypes>
+//   tuple<TTypes..., UTypes...>
+//   tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>& u);
+//
+// template <class... TTypes, class... UTypes>
+//   tuple<TTypes..., UTypes...>
+//   tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>&& u);
+//
+// template <class... TTypes, class... UTypes>
+//   tuple<TTypes..., UTypes...>
+//   tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        std::tuple<> t1;
+        std::tuple<> t2;
+        std::tuple<> t3 = std::tuple_cat(t1, t2);
+    }
+    {
+        std::tuple<> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == 2);
+    }
+    {
+        std::tuple<> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int*, int> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 2);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int, int*> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == nullptr);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int*, int, double> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == 3.5);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int, double, int*> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == 3.5);
+        assert(std::get<2>(t3) == nullptr);
+    }
+    {
+        std::tuple<int*, MoveOnly> t1(nullptr, 1);
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int*, MoveOnly, int, double> t3 =
+                                              std::tuple_cat(std::move(t1), t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 1);
+        assert(std::get<2>(t3) == 2);
+        assert(std::get<3>(t3) == 3.5);
+    }
+    {
+        std::tuple<int*, MoveOnly> t1(nullptr, 1);
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int, double, int*, MoveOnly> t3 =
+                                              std::tuple_cat(t2, std::move(t1));
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == 3.5);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+                                   std::tuple_cat(std::move(t1), std::move(t2));
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp b/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
new file mode 100644
index 0000000..d32fbde
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type const&
+//   get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        const T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        assert(d == 2.5);
+
+        std::get<1>(t) = "four";
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
new file mode 100644
index 0000000..2746f82
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type const&
+//   get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<int> T;
+        const T t(3);
+        assert(std::get<0>(t) == 3);
+    }
+    {
+        typedef std::tuple<std::string, int> T;
+        const T t("high", 5);
+        assert(std::get<0>(t) == "high");
+        assert(std::get<1>(t) == 5);
+    }
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        const T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        assert(d == 2.5);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
new file mode 100644
index 0000000..dc9d1ee
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type&
+//   get(tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<int> T;
+        T t(3);
+        assert(std::get<0>(t) == 3);
+        std::get<0>(t) = 2;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<std::string, int> T;
+        T t("high", 5);
+        assert(std::get<0>(t) == "high");
+        assert(std::get<1>(t) == 5);
+        std::get<0>(t) = "four";
+        std::get<1>(t) = 4;
+        assert(std::get<0>(t) == "four");
+        assert(std::get<1>(t) == 4);
+    }
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        std::get<1>(t) = "four";
+        std::get<2>(t) = 4;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "four");
+        assert(std::get<2>(t) == 4);
+        assert(d == 2.5);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
new file mode 100644
index 0000000..e446e8c
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// class tuple_element<I, tuple<Types...> >
+// {
+// public:
+//     typedef Ti type;
+// };
+
+#include <tuple>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::tuple<int> T;
+        static_assert((std::is_same<std::tuple_element<0, T>::type,
+                                    int>::value), "");
+    }
+    {
+        typedef std::tuple<char, int> T;
+        static_assert((std::is_same<std::tuple_element<0, T>::type,
+                                    char>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, T>::type,
+                                    int>::value), "");
+    }
+    {
+        typedef std::tuple<int*, char, int> T;
+        static_assert((std::is_same<std::tuple_element<0, T>::type,
+                                    int*>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, T>::type,
+                                    char>::value), "");
+        static_assert((std::is_same<std::tuple_element<2, T>::type,
+                                    int>::value), "");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
new file mode 100644
index 0000000..3020b99
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+//   class tuple_size<tuple<Types...>>
+//     : public integral_constant<size_t, sizeof...(Types)> { };
+
+#include <tuple>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        static_assert((std::is_base_of<std::integral_constant<std::size_t, 0>,
+                                      std::tuple_size<T> >::value), "");
+    }
+    {
+        typedef std::tuple<int> T;
+        static_assert((std::is_base_of<std::integral_constant<std::size_t, 1>,
+                                      std::tuple_size<T> >::value), "");
+    }
+    {
+        typedef std::tuple<char, int> T;
+        static_assert((std::is_base_of<std::integral_constant<std::size_t, 2>,
+                                      std::tuple_size<T> >::value), "");
+    }
+    {
+        typedef std::tuple<char, char*, int> T;
+        static_assert((std::is_base_of<std::integral_constant<std::size_t, 3>,
+                                      std::tuple_size<T> >::value), "");
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
new file mode 100644
index 0000000..9bab42e
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class InputIterator>
+//   InputIterator begin(const tuple<InputIterator, InputIterator>& t);
+
+// template <class InputIterator>
+//   InputIterator end(const tuple<InputIterator, InputIterator>& t);
+
+#include <tuple>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<int*, int*> T;
+        int array[5] = {0, 1, 2, 3, 4};
+        const T t(std::begin(array), std::end(array));
+        assert(begin(t) == std::begin(array));
+        assert(end(t) == std::end(array));
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
new file mode 100644
index 0000000..4fb08df
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T1;
+        typedef std::tuple<> T2;
+        const T1 t1;
+        const T2 t2;
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1.1);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1);
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, char(2));
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, char(3));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, char(2));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, char(3));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 3);
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 4);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 3, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 3, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
new file mode 100644
index 0000000..4ebaf6f
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T1;
+        typedef std::tuple<> T2;
+        const T1 t1;
+        const T2 t2;
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(0.9);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1.1);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 2);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(0.9, 2);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, 2);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 1);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 3);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(0.9, 2, 3);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 1, 3);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 2);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 4);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..534c6e0
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+//   void swap(tuple<Types...>& x, tuple<Types...>& y);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t1;
+        swap(t0, t1);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t1(MoveOnly(1));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 1);
+        assert(std::get<0>(t1) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t1(MoveOnly(2), MoveOnly(3));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 2);
+        assert(std::get<1>(t0) == 3);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 3);
+        assert(std::get<1>(t0) == 4);
+        assert(std::get<2>(t0) == 5);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+        assert(std::get<2>(t1) == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
new file mode 100644
index 0000000..64e4095
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// void swap(tuple& rhs);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t1;
+        t0.swap(t1);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t1(MoveOnly(1));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 1);
+        assert(std::get<0>(t1) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t1(MoveOnly(2), MoveOnly(3));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 2);
+        assert(std::get<1>(t0) == 3);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 3);
+        assert(std::get<1>(t0) == 4);
+        assert(std::get<2>(t0) == 5);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+        assert(std::get<2>(t1) == 2);
+    }
+}
diff --git a/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
new file mode 100644
index 0000000..80f141f
--- /dev/null
+++ b/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types, class Alloc>
+//   struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
+
+#include <tuple>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<char, int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<double&, char, int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+}
diff --git a/test/utilities/tuple/version.pass.cpp b/test/utilities/tuple/version.pass.cpp
new file mode 100644
index 0000000..7c7c35c
--- /dev/null
+++ b/test/utilities/tuple/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+#include <tuple>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/utilities/type.index/type.index.hash/hash.pass.cpp b/test/utilities/type.index/type.index.hash/hash.pass.cpp
new file mode 100644
index 0000000..25d4725
--- /dev/null
+++ b/test/utilities/type.index/type.index.hash/hash.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// template <>
+// struct hash<type_index>
+//     : public unary_function<type_index, size_t>
+// {
+//     size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    assert(std::hash<std::type_index>()(t1) == t1.hash_code());
+}
diff --git a/test/utilities/type.index/type.index.members/ctor.pass.cpp b/test/utilities/type.index/type.index.members/ctor.pass.cpp
new file mode 100644
index 0000000..14a019a
--- /dev/null
+++ b/test/utilities/type.index/type.index.members/ctor.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_info& rhs);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+}
diff --git a/test/utilities/type.index/type.index.members/eq.pass.cpp b/test/utilities/type.index/type.index.members/eq.pass.cpp
new file mode 100644
index 0000000..0dccef0
--- /dev/null
+++ b/test/utilities/type.index/type.index.members/eq.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator==(const type_index& rhs) const;
+// bool operator!=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    std::type_index t2 = typeid(int);
+    std::type_index t3 = typeid(long);
+    assert(t1 == t2);
+    assert(t1 != t3);
+}
diff --git a/test/utilities/type.index/type.index.members/hash_code.pass.cpp b/test/utilities/type.index/type.index.members/hash_code.pass.cpp
new file mode 100644
index 0000000..e0b614f
--- /dev/null
+++ b/test/utilities/type.index/type.index.members/hash_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// size_t hash_code() const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& ti = typeid(int);
+    std::type_index t1 = typeid(int);
+    assert(t1.hash_code() == ti.hash_code());
+}
diff --git a/test/utilities/type.index/type.index.members/lt.pass.cpp b/test/utilities/type.index/type.index.members/lt.pass.cpp
new file mode 100644
index 0000000..c047bdc
--- /dev/null
+++ b/test/utilities/type.index/type.index.members/lt.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator< (const type_index& rhs) const;
+// bool operator<=(const type_index& rhs) const;
+// bool operator> (const type_index& rhs) const;
+// bool operator>=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    std::type_index t2 = typeid(int);
+    std::type_index t3 = typeid(long);
+    assert(!(t1 <  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >  t2));
+    assert( (t1 >= t2));
+    assert(!(t1 <  t3));
+    assert(!(t1 <= t3));
+    assert( (t1 >  t3));
+    assert( (t1 >= t3));
+}
diff --git a/test/utilities/type.index/type.index.members/name.pass.cpp b/test/utilities/type.index/type.index.members/name.pass.cpp
new file mode 100644
index 0000000..9075a46
--- /dev/null
+++ b/test/utilities/type.index/type.index.members/name.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// const char* name() const;
+
+#include <typeindex>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& ti = typeid(int);
+    std::type_index t1 = typeid(int);
+    assert(std::string(t1.name()) == ti.name());
+}
diff --git a/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp b/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp
new file mode 100644
index 0000000..872b175
--- /dev/null
+++ b/test/utilities/type.index/type.index.overview/copy_assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index& operator=(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1(typeid(int));
+    std::type_index t2(typeid(double));
+    assert(t2 != t1);
+    t2 = t1;
+    assert(t2 == t1);
+}
diff --git a/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp b/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
new file mode 100644
index 0000000..08d7f3f
--- /dev/null
+++ b/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1(typeid(int));
+    std::type_index t2 = t1;
+    assert(t2 == t1);
+}
diff --git a/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
new file mode 100644
index 0000000..9a79a50
--- /dev/null
+++ b/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// struct hash<type_index>
+//     : public unary_function<type_index, size_t>
+// {
+//     size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::unary_function<std::type_index, std::size_t>,
+                                   std::hash<std::type_index> >::value), "");
+}
diff --git a/test/utilities/type.index/version.pass.cpp b/test/utilities/type.index/version.pass.cpp
new file mode 100644
index 0000000..6310ecd
--- /dev/null
+++ b/test/utilities/type.index/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+#include <typeindex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/utilities/utilities.general/nothing_to_do.pass.cpp b/test/utilities/utilities.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utilities.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp b/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility/declval/declval.pass.cpp b/test/utilities/utility/declval/declval.pass.cpp
new file mode 100644
index 0000000..eacf1f1
--- /dev/null
+++ b/test/utilities/utility/declval/declval.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
+
+#include <utility>
+#include <type_traits>
+
+class A
+{
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
+#else
+    static_assert((std::is_same<decltype(std::declval<A>()), A>::value), "");
+#endif
+}
diff --git a/test/utilities/utility/forward/forward.pass.cpp b/test/utilities/utility/forward/forward.pass.cpp
new file mode 100644
index 0000000..1667491
--- /dev/null
+++ b/test/utilities/utility/forward/forward.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+typedef char one;
+struct two {one _[2];};
+struct four {one _[4];};
+struct eight {one _[8];};
+
+one test(A&);
+two test(const A&);
+
+#ifdef _LIBCPP_MOVE
+
+four test(A&&);
+eight test(const A&&);
+
+#endif
+
+int main()
+{
+    A a;
+    const A ca = A();
+
+#ifdef _LIBCPP_MOVE
+    static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+    static_assert(sizeof(test(std::forward<A>(a))) == 4, "");
+    static_assert(sizeof(test(std::forward<A>(source()))) == 4, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+//    static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(a))) == 8, "");
+    static_assert(sizeof(test(std::forward<const A>(source()))) == 8, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+//    static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(ca))) == 8, "");
+    static_assert(sizeof(test(std::forward<const A>(csource()))) == 8, "");
+
+#else
+
+    static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+    static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
+//    static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
+#endif
+}
diff --git a/test/utilities/utility/forward/forward1.fail.cpp b/test/utilities/utility/forward/forward1.fail.cpp
new file mode 100644
index 0000000..eab3b8b
--- /dev/null
+++ b/test/utilities/utility/forward/forward1.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    std::forward<A&>(source());  // error
+}
diff --git a/test/utilities/utility/forward/forward2.fail.cpp b/test/utilities/utility/forward/forward2.fail.cpp
new file mode 100644
index 0000000..e2c3874
--- /dev/null
+++ b/test/utilities/utility/forward/forward2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A&>(ca);  // error
+}
diff --git a/test/utilities/utility/forward/forward3.fail.cpp b/test/utilities/utility/forward/forward3.fail.cpp
new file mode 100644
index 0000000..3a681fc
--- /dev/null
+++ b/test/utilities/utility/forward/forward3.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    std::forward<A&>(csource());  // error
+}
diff --git a/test/utilities/utility/forward/forward4.fail.cpp b/test/utilities/utility/forward/forward4.fail.cpp
new file mode 100644
index 0000000..f6e0036
--- /dev/null
+++ b/test/utilities/utility/forward/forward4.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A>(ca);  // error
+}
diff --git a/test/utilities/utility/forward/forward5.fail.cpp b/test/utilities/utility/forward/forward5.fail.cpp
new file mode 100644
index 0000000..a590ea6
--- /dev/null
+++ b/test/utilities/utility/forward/forward5.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A>(csource());  // error
+}
diff --git a/test/utilities/utility/forward/forward6.fail.cpp b/test/utilities/utility/forward/forward6.fail.cpp
new file mode 100644
index 0000000..0c13448
--- /dev/null
+++ b/test/utilities/utility/forward/forward6.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+int main()
+{
+    A a;
+    std::forward(a);  // error
+}
diff --git a/test/utilities/utility/forward/move_copy.pass.cpp b/test/utilities/utility/forward/move_copy.pass.cpp
new file mode 100644
index 0000000..94a27d5
--- /dev/null
+++ b/test/utilities/utility/forward/move_copy.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+int copy_ctor = 0;
+int move_ctor = 0;
+
+class A
+{
+#ifdef _LIBCPP_MOVE
+#else
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    A(const A&) {++copy_ctor;}
+    A& operator=(const A&);
+
+    A(A&&) {++move_ctor;}
+    A& operator=(A&&);
+#else
+    A(const A&) {++copy_ctor;}
+    A& operator=(A&);
+
+    operator std::__rv<A> () {return std::__rv<A>(*this);}
+    A(std::__rv<A>) {++move_ctor;}
+#endif
+
+    A() {}
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+void test(A) {}
+
+int main()
+{
+    A a;
+    const A ca = A();
+
+    assert(copy_ctor == 0);
+    assert(move_ctor == 0);
+
+    A a2 = a;
+    assert(copy_ctor == 1);
+    assert(move_ctor == 0);
+
+    A a3 = std::move(a);
+    assert(copy_ctor == 1);
+    assert(move_ctor == 1);
+
+    A a4 = ca;
+    assert(copy_ctor == 2);
+    assert(move_ctor == 1);
+
+    A a5 = std::move(ca);
+    assert(copy_ctor == 3);
+    assert(move_ctor == 1);
+}
diff --git a/test/utilities/utility/forward/move_if_noexcept.pass.cpp b/test/utilities/utility/forward/move_if_noexcept.pass.cpp
new file mode 100644
index 0000000..1646b20
--- /dev/null
+++ b/test/utilities/utility/forward/move_if_noexcept.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T>
+//     typename conditional
+//     <
+//         !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
+//         const T&,
+//         T&&
+//     >::type
+//     move_if_noexcept(T& x);
+
+#include <utility>
+
+class A
+{
+    A(const A&);
+    A& operator=(const A&);
+public:
+
+    A() {}
+#ifdef _LIBCPP_MOVE
+    A(A&&) {}
+#endif
+};
+
+int main()
+{
+    int i = 0;
+    const int ci = 0;
+
+    A a;
+    const A ca;
+
+#ifdef _LIBCPP_MOVE
+    static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), "");
+#else
+    static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
+#endif
+
+}
diff --git a/test/utilities/utility/forward/move_only.pass.cpp b/test/utilities/utility/forward/move_only.pass.cpp
new file mode 100644
index 0000000..350ed86
--- /dev/null
+++ b/test/utilities/utility/forward/move_only.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+#ifdef _LIBCPP_MOVE
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only mo;
+
+    test(std::move(mo));
+    test(source());
+}
diff --git a/test/utilities/utility/forward/move_only1.fail.cpp b/test/utilities/utility/forward/move_only1.fail.cpp
new file mode 100644
index 0000000..53559bc
--- /dev/null
+++ b/test/utilities/utility/forward/move_only1.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifdef _LIBCPP_MOVE
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(a);
+}
diff --git a/test/utilities/utility/forward/move_only2.fail.cpp b/test/utilities/utility/forward/move_only2.fail.cpp
new file mode 100644
index 0000000..7f4eff5
--- /dev/null
+++ b/test/utilities/utility/forward/move_only2.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifdef _LIBCPP_MOVE
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(ca);
+}
diff --git a/test/utilities/utility/forward/move_only3.fail.cpp b/test/utilities/utility/forward/move_only3.fail.cpp
new file mode 100644
index 0000000..a6f87cf
--- /dev/null
+++ b/test/utilities/utility/forward/move_only3.fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+#ifdef _LIBCPP_MOVE
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(std::move(ca));
+}
diff --git a/test/utilities/utility/forward/move_only4.fail.cpp b/test/utilities/utility/forward/move_only4.fail.cpp
new file mode 100644
index 0000000..181aa34
--- /dev/null
+++ b/test/utilities/utility/forward/move_only4.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifdef _LIBCPP_MOVE
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif
+
+public:
+
+#ifdef _LIBCPP_MOVE
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(csource());
+}
diff --git a/test/utilities/utility/operators/rel_ops.pass.cpp b/test/utilities/utility/operators/rel_ops.pass.cpp
new file mode 100644
index 0000000..4be33ea
--- /dev/null
+++ b/test/utilities/utility/operators/rel_ops.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test rel_ops
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+    int data_;
+
+    explicit A(int data = -1) : data_(data) {}
+};
+
+inline
+bool
+operator == (const A& x, const A& y)
+{
+    return x.data_ == y.data_;
+}
+
+inline
+bool
+operator < (const A& x, const A& y)
+{
+    return x.data_ < y.data_;
+}
+
+int main()
+{
+    using namespace std::rel_ops;
+    A a1(1);
+    A a2(2);
+    assert(a1 == a1);
+    assert(a1 != a2);
+    assert(a1 < a2);
+    assert(a2 > a1);
+    assert(a1 <= a1);
+    assert(a1 <= a2);
+    assert(a2 >= a2);
+    assert(a2 >= a1);
+}
diff --git a/test/utilities/utility/pairs/nothing_to_do.pass.cpp b/test/utilities/utility/pairs/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility/pairs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp b/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
new file mode 100644
index 0000000..b9a53ad
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     const typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        const P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+        std::get<0>(p) = 5;
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp b/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
new file mode 100644
index 0000000..a04f16f
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     const typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        const P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp b/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
new file mode 100644
index 0000000..27e207b
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+        std::get<0>(p) = 5;
+        std::get<1>(p) = 6;
+        assert(std::get<0>(p) == 5);
+        assert(std::get<1>(p) == 6);
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
new file mode 100644
index 0000000..0edf08b
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_element<I, pair<T1, T2> >::type
+
+#include <utility>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        static_assert((std::is_same<std::tuple_element<0, P1>::type, int>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, P1>::type, short>::value), "");
+    }
+    {
+        typedef std::pair<int*, char> P1;
+        static_assert((std::is_same<std::tuple_element<0, P1>::type, int*>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, P1>::type, char>::value), "");
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
new file mode 100644
index 0000000..eba41f1
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_size<pair<T1, T2> >::value
+
+#include <utility>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        static_assert((std::tuple_size<P1>::value == 2), "");
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp b/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
new file mode 100644
index 0000000..106eed9
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// struct piecewise_construct_t { };
+// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+#include <utility>
+
+int main()
+{
+    std::piecewise_construct_t p = std::piecewise_construct;
+}
diff --git a/test/utilities/utility/pairs/pair.range/begin.pass.cpp b/test/utilities/utility/pairs/pair.range/begin.pass.cpp
new file mode 100644
index 0000000..7f7de29
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.range/begin.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class InputIterator>
+//     InputIterator
+//     begin(const std::pair<InputIterator, InputIterator>& p);
+
+#include <utility>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int*, int*> P;
+        int a[3] = {0};
+        P p(std::begin(a), std::end(a));
+        assert(std::begin(p) == a);
+    }
+}
diff --git a/test/utilities/utility/pairs/pair.range/end.pass.cpp b/test/utilities/utility/pairs/pair.range/end.pass.cpp
new file mode 100644
index 0000000..b1d8dac
--- /dev/null
+++ b/test/utilities/utility/pairs/pair.range/end.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class InputIterator>
+//     InputIterator
+//     end(const std::pair<InputIterator, InputIterator>& p);
+
+#include <utility>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int*, int*> P;
+        int a[3] = {0};
+        P p(std::begin(a), std::end(a));
+        assert(std::end(p) == a+3);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp b/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..fa4d462
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp b/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
new file mode 100644
index 0000000..c4ecf6e
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair(U&& x, V&& y);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<std::unique_ptr<int>, short*> P;
+        P p(std::unique_ptr<int>(new int(3)), nullptr);
+        assert(*p.first == 3);
+        assert(p.second == nullptr);
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp b/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
new file mode 100644
index 0000000..99f2991
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        typedef std::pair<double, long> P2;
+        P1 p1(3, 4);
+        P2 p2;
+        p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp b/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
new file mode 100644
index 0000000..2c7b2bd
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair& operator=(pair&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P;
+        P p1(std::unique_ptr<int>(new int(3)), 4);
+        P p2;
+        p2 = std::move(p1);
+        assert(*p2.first == 3);
+        assert(p2.second == 4);
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp b/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
new file mode 100644
index 0000000..0048ce8
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+    virtual ~Base() {}
+};
+
+struct Derived
+    : public Base
+{
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<std::unique_ptr<Derived>, short> P1;
+        typedef std::pair<std::unique_ptr<Base>, long> P2;
+        P1 p1(std::unique_ptr<Derived>(), 4);
+        P2 p2;
+        p2 = std::move(p1);
+        assert(p2.first == nullptr);
+        assert(p2.second == 4);
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/comparison.pass.cpp b/test/utilities/utility/pairs/pairs.pair/comparison.pass.cpp
new file mode 100644
index 0000000..0c6297a
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/comparison.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(3, 4);
+        assert( (p1 == p2));
+        assert(!(p1 != p2));
+        assert(!(p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert( (p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(2, 4);
+        P p2(3, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert( (p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert(!(p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 2);
+        P p2(3, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert( (p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert(!(p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(2, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert(!(p1 <  p2));
+        assert(!(p1 <= p2));
+        assert( (p1 >  p2));
+        assert( (p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(3, 2);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert(!(p1 <  p2));
+        assert(!(p1 <= p2));
+        assert( (p1 >  p2));
+        assert( (p1 >= p2));
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp b/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
new file mode 100644
index 0000000..d13b1c5
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const T1& x, const T2& y);
+
+#include <utility>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A(int data) : data_(data) {}
+
+    bool operator==(const A& a) {return data_ == a.data_;}
+};
+
+int main()
+{
+    {
+        typedef std::pair<float, short*> P;
+        P p(3.5f, 0);
+        assert(p.first == 3.5f);
+        assert(p.second == nullptr);
+    }
+    {
+        typedef std::pair<A, int> P;
+        P p(1, 2);
+        assert(p.first == A(1));
+        assert(p.second == 2);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
new file mode 100644
index 0000000..86fa790
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        typedef std::pair<double, long> P2;
+        P1 p1(3, 4);
+        P2 p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp b/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
new file mode 100644
index 0000000..874d17e
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const pair&) = default;
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/utilities/utility/pairs/pairs.pair/default.pass.cpp
new file mode 100644
index 0000000..16ff4bd
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// constexpr pair();
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    typedef std::pair<float, short*> P;
+    P p;
+    assert(p.first == 0.0f);
+    assert(p.second == nullptr);
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/make_pair.pass.cpp b/test/utilities/utility/pairs/pairs.pair/make_pair.pass.cpp
new file mode 100644
index 0000000..60e7e10
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/make_pair.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1 = std::make_pair(3, 4);
+        assert(p1.first == 3);
+        assert(p1.second == 4);
+    }
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P1;
+        P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), 4);
+        assert(*p1.first == 3);
+        assert(p1.second == 4);
+    }
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P1;
+        P1 p1 = std::make_pair(nullptr, 4);
+        assert(p1.first == nullptr);
+        assert(p1.second == 4);
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/non_member_swap.pass.cpp b/test/utilities/utility/pairs/pairs.pair/non_member_swap.pass.cpp
new file mode 100644
index 0000000..626d98f
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/non_member_swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2(5, 6);
+        swap(p1, p2);
+        assert(p1.first == 5);
+        assert(p1.second == 6);
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp b/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
new file mode 100644
index 0000000..3f41102
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class... Args1, class... Args2>
+//     pair(piecewise_construct_t, tuple<Args1...> first_args,
+//                                 tuple<Args2...> second_args);
+
+#include <utility>
+#include <tuple>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        typedef std::pair<int, int*> P1;
+        typedef std::pair<int*, int> P2;
+        typedef std::pair<P1, P2> P3;
+        P3 p3(std::piecewise_construct, std::tuple<int, int*>(3, nullptr),
+                                        std::tuple<int*, int>(nullptr, 4));
+        assert(p3.first == P1(3, nullptr));
+        assert(p3.second == P2(nullptr, 4));
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
new file mode 100644
index 0000000..0476a37
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+    virtual ~Base() {}
+};
+
+struct Derived
+    : public Base
+{
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        typedef std::pair<std::unique_ptr<Derived>, short> P1;
+        typedef std::pair<std::unique_ptr<Base>, long> P2;
+        P1 p1(std::unique_ptr<Derived>(), 4);
+        P2 p2 = std::move(p1);
+        assert(p2.first == nullptr);
+        assert(p2.second == 4);
+    }
+#endif
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp
new file mode 100644
index 0000000..2898144
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// void swap(pair& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2(5, 6);
+        p1.swap(p2);
+        assert(p1.first == 5);
+        assert(p1.second == 6);
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/test/utilities/utility/pairs/pairs.pair/types.pass.cpp b/test/utilities/utility/pairs/pairs.pair/types.pass.cpp
new file mode 100644
index 0000000..dd217a5
--- /dev/null
+++ b/test/utilities/utility/pairs/pairs.pair/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2>
+// struct pair
+// {
+//     typedef T1 first_type;
+//     typedef T2 second_type;
+
+
+#include <utility>
+#include <type_traits>
+
+int main()
+{
+    typedef std::pair<float, short*> P;
+    static_assert((std::is_same<P::first_type, float>::value), "");
+    static_assert((std::is_same<P::second_type, short*>::value), "");
+}
diff --git a/test/utilities/utility/utility.swap/swap.pass.cpp b/test/utilities/utility/utility.swap/swap.pass.cpp
new file mode 100644
index 0000000..acb3664
--- /dev/null
+++ b/test/utilities/utility/utility.swap/swap.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T> 
+//   requires MoveAssignable<T> && MoveConstructible<T> 
+//   void
+//   swap(T& a, T& b);
+
+#include <utility>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+void
+test()
+{
+    int i = 1;
+    int j = 2;
+    std::swap(i, j);
+    assert(i == 2);
+    assert(j == 1);
+}
+
+#ifdef _LIBCPP_MOVE
+
+void
+test1()
+{
+    std::unique_ptr<int> i(new int(1));
+    std::unique_ptr<int> j(new int(2));
+    std::swap(i, j);
+    assert(*i == 2);
+    assert(*j == 1);
+}
+
+#endif
+
+int main()
+{
+    test();
+#ifdef _LIBCPP_MOVE
+    test1();
+#endif
+}
diff --git a/test/utilities/utility/utility.swap/swap_array.pass.cpp b/test/utilities/utility/utility.swap/swap_array.pass.cpp
new file mode 100644
index 0000000..1ab1689
--- /dev/null
+++ b/test/utilities/utility/utility.swap/swap_array.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<ValueType T, size_t N> 
+//   requires Swappable<T> 
+//   void
+//   swap(T (&a)[N], T (&b)[N]);
+
+#include <utility>
+#include <cassert>
+#ifdef _LIBCPP_MOVE
+#include <memory>
+#endif
+
+void
+test()
+{
+    int i[3] = {1, 2, 3};
+    int j[3] = {4, 5, 6};
+    std::swap(i, j);
+    assert(i[0] == 4);
+    assert(i[1] == 5);
+    assert(i[2] == 6);
+    assert(j[0] == 1);
+    assert(j[1] == 2);
+    assert(j[2] == 3);
+}
+
+#ifdef _LIBCPP_MOVE
+
+void
+test1()
+{
+    std::unique_ptr<int> i[3];
+    for (int k = 0; k < 3; ++k)
+        i[k].reset(new int(k+1));
+    std::unique_ptr<int> j[3];
+    for (int k = 0; k < 3; ++k)
+        j[k].reset(new int(k+4));
+    std::swap(i, j);
+    assert(*i[0] == 4);
+    assert(*i[1] == 5);
+    assert(*i[2] == 6);
+    assert(*j[0] == 1);
+    assert(*j[1] == 2);
+    assert(*j[2] == 3);
+}
+
+#endif
+
+int main()
+{
+    test();
+#ifdef _LIBCPP_MOVE
+    test1();
+#endif
+}
diff --git a/test/utilities/utility/version.pass.cpp b/test/utilities/utility/version.pass.cpp
new file mode 100644
index 0000000..5eb9b21
--- /dev/null
+++ b/test/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+#include <utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}